Copy data next to a cell and paste it below
Solved/Closed
Related:
- Copy data next to a cell and paste it below
- Tmobile data check - Guide
- Transfer data from one excel worksheet to another automatically - Guide
- Gta 5 data download for pc - Download - Action and adventure
- Data transmission cable - Guide
- Digital data transmission - Guide
3 responses
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
May 6, 2010 at 10:34 PM
May 6, 2010 at 10:34 PM
first copy the data in sheet2 .
then try the macro "test"
sorry there will be bug ignore solution
then try the macro "test"
Sub test() Dim j As Integer, k As Integer Worksheets("sheet1").Activate j = Range("A1").End(xlDown).Row For k = j To 1 Step -1 If Cells(k, "C") <> "" Then If k = 1 Then Cells(k + 1, "A").EntireRow.Insert Cells(k, "c").Cut Cells(k + 1, "B") Cells(k + 2, "A").EntireRow.FormulaArray = "'-----------------" Exit Sub End If Cells(k, "A").EntireRow.Insert Cells(k + 1, "C").Cut Cells(k + 2, "B") Cells(k + 3, "A").EntireRow.FormulaArray = "'-----------------" Else Cells(k, "A").EntireRow.Insert Cells(k + 2, "a").EntireRow.FormulaArray = "'-----------------" End If Next k End Sub
Sub undo() Worksheets("sheet1").Cells.Clear Worksheets("sheet2").Cells.Copy Worksheets("sheet1").Range("A1") End Sub
sorry there will be bug ignore solution
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
May 7, 2010 at 05:19 AM
May 7, 2010 at 05:19 AM
the solution I have given may even otherwise give bug. so I said at the end of the message ignore solution. I shall think about a valid solution
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
May 7, 2010 at 06:41 AM
May 7, 2010 at 06:41 AM
Try this
Assumptions:
1. Record start from Row 1
Assumptions:
1. Record start from Row 1
Sub MoveAndFormat() Dim lMaxRows As Long 'max rows in the sheet Dim lThisRow As Long 'row being processed Dim iMaxCol As Integer 'max used column in the row being processed lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row lThisRow = 1 'start from row 1 Do While lThisRow <= lMaxRows iMaxCol = Cells(lThisRow, Columns.Count).End(xlToLeft).Column If (iMaxCol > 2) Then Rows(lThisRow + 1 & ":" & lThisRow + 1).Insert Range(Cells(lThisRow, 3), Cells(lThisRow, iMaxCol)).Copy Range("B" & lThisRow + 1).Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False Rows(lThisRow + 1).Select Range(Cells(lThisRow, 3), Cells(lThisRow, iMaxCol)).Clear lThisRow = lThisRow + 1 lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row Else Rows(lThisRow).Select End If With Selection.Borders(xlEdgeBottom) .LineStyle = xlDash .Weight = xlMedium .ColorIndex = xlAutomatic End With lThisRow = lThisRow + 1 Loop End Sub
May 7, 2010 at 12:58 AM