Kaniguan1969
07-23-2014, 09:46 PM
Hi,
Am trying to automatically copy the contents of the columns B4,C4 combination of
D4&E4,H4 to AU4, AWX4, AX4. Records will until the last not empty row of column B.
then copied to another sheet of the same workbook to the last empty row. Thank you.
Here is my initial code. the issue with code.
1. i cant combine the column D4 and E4
2. I have 9 rows with records but it captures up to 15 rows. basically it should capture until row 9 which it has an exist records.
Sub Button274_Click()
Dim ws As Worksheet
Dim my_range As Range
Set my_range = ThisWorkbook.Sheets("MDX SDS").Range("B4,C4,D4:E4,H4,I4,J4,K4,L4,M4,N4,O4,P4,Q4,R4,S4,T4,U4,V4,W4,X4,Y4,Z4,AA4,AB 4,AC4,AD4,AE4,AF4,AG4,AH4,AI4,AJ4,AK4,AL4,AM4,AN4,AO4,AP4,APU4")
Set ws = ThisWorkbook.Sheets("Test")
Do
If Application.WorksheetFunction.CountA(my_range) > 0 Then
my_range.Copy ws.Range("B" & ws.Rows.Count).End(xlUp).Offset(1, 0)
Set my_range = my_range.Offset(1, 0)
Debug.Print my_range.Address
Else
Exit Do
End If
Loop
End Sub
Am trying to automatically copy the contents of the columns B4,C4 combination of
D4&E4,H4 to AU4, AWX4, AX4. Records will until the last not empty row of column B.
then copied to another sheet of the same workbook to the last empty row. Thank you.
Here is my initial code. the issue with code.
1. i cant combine the column D4 and E4
2. I have 9 rows with records but it captures up to 15 rows. basically it should capture until row 9 which it has an exist records.
Sub Button274_Click()
Dim ws As Worksheet
Dim my_range As Range
Set my_range = ThisWorkbook.Sheets("MDX SDS").Range("B4,C4,D4:E4,H4,I4,J4,K4,L4,M4,N4,O4,P4,Q4,R4,S4,T4,U4,V4,W4,X4,Y4,Z4,AA4,AB 4,AC4,AD4,AE4,AF4,AG4,AH4,AI4,AJ4,AK4,AL4,AM4,AN4,AO4,AP4,APU4")
Set ws = ThisWorkbook.Sheets("Test")
Do
If Application.WorksheetFunction.CountA(my_range) > 0 Then
my_range.Copy ws.Range("B" & ws.Rows.Count).End(xlUp).Offset(1, 0)
Set my_range = my_range.Offset(1, 0)
Debug.Print my_range.Address
Else
Exit Do
End If
Loop
End Sub