I would like integrate two macros code in to one. The first macros code is used to find the exact number of rows in a specific column. The second macros code is used to do a certain set of changes in the worksheet. I need the result of the first macros code to automatically be inserted in the second macros code. ( basically where the range is defined)
Macros code 1
Sub sbLastRowOfDColumn()
'Find the last Row with data in a Column
'In this example we are finding the last row of column D
Dim lastRow As Long
With ActiveSheet
lastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
End With
MsgBox lastRow
End Sub
Macros code 2
Sub test()
Range("A1").Select
ActiveCell.FormulaR1C1 = "variable1"
Columns("A:A").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = "gdgs"
Range("A2").Select
ActiveCell.FormulaR1C1 = "6"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A360"), Type:=xlFillDefault
'need the result of last row at the place of A360
Range("A2:A360").Select
ActiveWindow.SmallScroll Down:=-1034
Range("B1").Select
ActiveCell.FormulaR1C1 = "dgdgsg"
Range("C1").Select
ActiveCell.FormulaR1C1 = "gdsgsdgsd"
Range("D1").Select
ActiveCell.FormulaR1C1 = "sdgsdgsfh"
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Range("E1").Select
ActiveCell.FormulaR1C1 = "dgsdgsgs"
Range("F1").Select
ActiveCell.FormulaR1C1 = "url"
Range("G:G,H:H,I:I,J:J,K:K,L:L,M:M").Select
Range("M1").Activate
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.ClearContents
Range("D1").Select
ActiveCell.FormulaR1C1 = "dgdfggsdgh"
Range("D2").Select
ActiveCell.FormulaR1C1 = "dgsdgdshshdh"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D360"), Type:=xlFillDefault
'need the result of last row at the place of D360
Range("D2:D360").Select
ActiveWindow.SmallScroll Down:=-984
End Sub