Uptickdk
04-29-2013, 12:18 AM
I have a number of worksheets and need to copy G2:G9999999 from each worksheet onto Sheet1 called ("Parameters") starting in column K then L, M... I also need to copy the name of each worksheet into the top cell of the column it's data was copied into. i.e. K1, L1,M1 ... I also need to copy the any of the sheets column A2:A2500 into my "Parameters" worksheet in column J, they are dates
I'm a Newbee with VBA and not sure what my errors are or how to combine all three to subs into one.
Lastly I would like to delete any columns from J onward before running the script.
Thanks for any help,
Doug
Sub Getdata()
Dim wrk As Workbook
Dim wkst As Worksheet
Dim Column As Long
Column = 11
Set wrk = ActiveWorkbook
For Each wkst In wrk.Worksheets
' loop through all Open worksheets
If wkst.Name <> "Parameters" Then
Worksheets("Parameters").Cells(1, Column) = wkst.Range("G2:G2500")
Column = Column + 1
End If
Next
End Sub
Sub GetName()
Dim wrk As Workbook
Dim wkst As Worksheet
Dim Column As Long
Column = 11
Set wrk = ActiveWorkbook
For Each wkst In wrk.Worksheets
' loop through all Open worksheets
If wkst.Name <> "Parameters" Then
Worksheets("Parameters").Cells(1, Column).Value = wkst.Name
Column = Column + 1
End If
Next
End Sub
Sub GetDates()
Dim wrk As Workbook
Dim wkst As Worksheet
Set wrk = ActiveWorkbook
Sheets("A11").Select
Worksheet("A11").Range("a2:a2500").Select
Selection.Copy
Sheets("Parameters").Select
Range("J1").Select
ActiveSheet.Paste
End Sub
I'm a Newbee with VBA and not sure what my errors are or how to combine all three to subs into one.
Lastly I would like to delete any columns from J onward before running the script.
Thanks for any help,
Doug
Sub Getdata()
Dim wrk As Workbook
Dim wkst As Worksheet
Dim Column As Long
Column = 11
Set wrk = ActiveWorkbook
For Each wkst In wrk.Worksheets
' loop through all Open worksheets
If wkst.Name <> "Parameters" Then
Worksheets("Parameters").Cells(1, Column) = wkst.Range("G2:G2500")
Column = Column + 1
End If
Next
End Sub
Sub GetName()
Dim wrk As Workbook
Dim wkst As Worksheet
Dim Column As Long
Column = 11
Set wrk = ActiveWorkbook
For Each wkst In wrk.Worksheets
' loop through all Open worksheets
If wkst.Name <> "Parameters" Then
Worksheets("Parameters").Cells(1, Column).Value = wkst.Name
Column = Column + 1
End If
Next
End Sub
Sub GetDates()
Dim wrk As Workbook
Dim wkst As Worksheet
Set wrk = ActiveWorkbook
Sheets("A11").Select
Worksheet("A11").Range("a2:a2500").Select
Selection.Copy
Sheets("Parameters").Select
Range("J1").Select
ActiveSheet.Paste
End Sub