Macro to move data from one tab to another

vcason

New Member
Joined
May 8, 2017
Messages
11
Hello again! This forum helped me a few months ago with this macro to move data from one sheet ("Raw Data TY" & "Raw Data LY") to another ("Discount", "Group", Corporate", etc). The macro has been working well until I added the "Group" sheet.

What I need to happen is the data that is in the "Raw Data" sheets to be copy/pasted to the destination tab (Discount, Corporate, Group, etc) based on the value of column A. Everything is working correctly for the "Raw Data TY" sheet. However, the "Raw Data LY" sheet will not move Q,R,S,T,U,V over to the "Group" destination sheet - it only moves V. The same thing happens with "Comp" & W,X,Y,Z....it works correctly for the "TY" data, but not "LY".

ABCDEFG
1D
11A4N8

<tbody>
</tbody>
D20ABR7/30 - 8/6/1710G26Y204.44
2Q11A8D3SGR2397/28 - 7/29/171181MN239
3T1186RISGR2297/6 - 7/10/171186GP229
4V11A465SGR2157/11 - 7/14/161104YS215

<tbody>
</tbody>


Macro is below:

Sub CopyStuff()
Dim sh1 As Worksheet, sh2 As Worksheet, dsh As Worksheet, shAry As Variant, dAry As Variant, i As Long, j As Long
Set sh1 = Sheets("Raw Data TY")
Set sh2 = Sheets("Raw Data LY")
shAry = Array(sh1, sh2)
dAry = Array("A", "B", "C", "D", "E", "F", "G", "I", "Q", "R", "S", "T", "U", "V", "O", "W", "X", "Y", "Z")
For i = LBound(shAry) To UBound(shAry)
For j = LBound(dAry) To UBound(dAry)
shAry(i).UsedRange.Offset(1).AutoFilter 1, dAry(j)
Select Case dAry(j)
Case "A"
Set dsh = Sheets("Leisure")
Case "B"
Set dsh = Sheets("Package")
Case "C"
Set dsh = Sheets("Consortia")
Case "D"
Set dsh = Sheets("Discount")
Case "E"
Set dsh = Sheets("FIT")
Case "F"
Set dsh = Sheets("Corporate")
Case "G"
Set dsh = Sheets("Govt")
Case "I"
Set dsh = Sheets("Echannel-OTA")
Case "Q" To "V"
Set dsh = Sheets("Group")
Case "W" To "Z"
Set dsh = Sheets("Comp")
Case "O"
Set dsh = Sheets("owner")
End Select
If shAry(i) Is sh1 Then
If dsh.Range("B44") = "" Then
shAry(i).UsedRange.Offset(2).SpecialCells(xlCellTypeVisible).Copy dsh.Range("B44")
Else
shAry(i).UsedRange.Offset(2).SpecialCells(xlCellTypeVisible).Copy dsh. _
Cells(Rows.Count, 2).End(xlUp)(2)
End If
Else
If dsh.Range("R44") = "" Then
shAry(i).UsedRange.Offset(2).SpecialCells(xlCellTypeVisible).Copy dsh.Range("R44")
Else
shAry(i).UsedRange.Offset(2).SpecialCells(xlCellTypeVisible).Copy dsh. _
Cells(Rows.Count, 11).End(xlUp)(2)
End If
End If
shAry(i).AutoFilterMode = False
Next
Next
End Sub


Appreciate the help!

~Vanessa
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,215,411
Messages
6,124,759
Members
449,187
Latest member
hermansoa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top