Small Paul
Board Regular
- Joined
- Jun 28, 2018
- Messages
- 118
Hi
I have a worksheet named "Required Data". In column A is a variable range of numbers (1,2,3,etc) and for each number there is a corresponding worksheet (named 1,2,3 etc).
I need to copy the data in columns D:M and paste it in the 1st empty row of the corresponding worksheet e.g if A2 is 1, paste D2:M2 in worksheet 1. I then need to loop until the column is blank.
This is what I have at the moment (thanks to a previous post by 'Fluff'):
If this is not possible, I have each of the worksheet names in cell L1 of each sheet. Would it be easier to Find the column A number via that?
Any help would be welcome.
Many thanks
Small Paul.
I have a worksheet named "Required Data". In column A is a variable range of numbers (1,2,3,etc) and for each number there is a corresponding worksheet (named 1,2,3 etc).
I need to copy the data in columns D:M and paste it in the 1st empty row of the corresponding worksheet e.g if A2 is 1, paste D2:M2 in worksheet 1. I then need to loop until the column is blank.
This is what I have at the moment (thanks to a previous post by 'Fluff'):
Code:
Sub Comms_Splitting_Data_2()'
' Comms_Splitting_Data_2 Macro
'
Dim a As Integer
Dim detail As String
Dim Wbk As Workbook
Set Wbk = Workbooks("Commission Statements.xlsm")
With Workbooks("Commission Statements.xlsm").Sheets("Required Data")
a = 1
Do Until IsEmpty(.Cells(a, 1))
Cells(2, 1).Activate
Range(Cells(0, 3), Cells(0, 13)).Copy
detail = Cells(a, 1).Value
Wbk.Sheets(detail).Visible = False
Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlValues
Sheets("Required Data").Activate
a = a + 1
Loop
End With
'
End Sub
If this is not possible, I have each of the worksheet names in cell L1 of each sheet. Would it be easier to Find the column A number via that?
Any help would be welcome.
Many thanks
Small Paul.