skeeeter56
New Member
- Joined
- Nov 26, 2016
- Messages
- 42
- Office Version
- 2019
- Platform
- Windows
I have a button when clicked runs some code which works perfect. What I want to do is when the code ends to move to next column and run again
This is the Main page the rows 20,30,40,55,74 and 75 from C to P each cell has this formula
Each Range for example in Row C20 Nuna1, D20 Nuna2 up to P20 Nuna14.
The same format is used for the other groups as it moves down the page.
Verm1 to Verm14, Mitch1 to Mitch14, Black1 to Black14, Boxh1 to Boxh14, Boxhi1 to Boxhi14
I have tried various ways to achieve but as yet have not bee able to master it. If anyone is able to help be most grateful
Private Sub cbPrintUMS1_Click()
Application.ScreenUpdating = False
' Get the worksheets
Dim shRead As Worksheet
Set shGroup1 = ThisWorkbook.Worksheets("Nunawading")
Set shGroup2 = ThisWorkbook.Worksheets("Vermont")
Set shGroup3 = ThisWorkbook.Worksheets("Mitcham")
Set shGroup4 = ThisWorkbook.Worksheets("Blackburn")
Set shGroup5 = ThisWorkbook.Worksheets("Box Hill 1")
Set shGroup6 = ThisWorkbook.Worksheets("Box Hill 2")
Set shData = ThisWorkbook.Worksheets("Week Commencing")
'Group1
If shData.Range("C20") = True Then
' This will copy to Nunawading Sheet
shData.Range("Nuna1").Copy
shGroup1.Range("D6").PasteSpecial , Paste:=xlPasteValues, Transpose:=True
shGroup1.PrintPreview
End If
'Group2
If shData.Range("C30") = True Then
' This will copy to Vermont Sheet
shData.Range("Verm1").Copy
shGroup2.Range("D6").PasteSpecial , Paste:=xlPasteValues, Transpose:=True
shGroup2.PrintPreview
End If
'Group3
If shData.Range("C40") = True Then
' This will copy to Mitcham Sheet
shData.Range("Mitch1").Copy
shGroup3.Range("D6").PasteSpecial , Paste:=xlPasteValues, Transpose:=True
shGroup3.PrintPreview
End If
'Group4
If shData.Range("C55") = True Then
' This will copy to Blackurn Sheet
shData.Range("Black1").Copy
shGroup4.Range("D6").PasteSpecial , Paste:=xlPasteValues, Transpose:=True
shGroup4.PrintPreview
End If
'Group5
If shData.Range("C74") = True Then
' This will copy to Box Hill 1 Sheet
shData.Range("Boxh1").Copy
shGroup5.Range("D6").PasteSpecial , Paste:=xlPasteValues, Transpose:=True
shGroup5.PrintPreview
End If
'Group6
If shData.Range("C75") = True Then
' This will copy to Box Hill 2
shData.Range("Boxhi1").Copy
shGroup6.Range("D6").PasteSpecial , Paste:=xlPasteValues, Transpose:=True
shGroup6.PrintPreview
End If
shGroup1.Range("Clear1").ClearContents
shGroup2.Range("Clear2").ClearContents
shGroup3.Range("Clear3").ClearContents
shGroup4.Range("Clear4").ClearContents
shGroup5.Range("Clear5").ClearContents
shGroup6.Range("Clear6").ClearContents
Application.ScreenUpdating = True
End Sub
This is the Main page the rows 20,30,40,55,74 and 75 from C to P each cell has this formula
=SUMPRODUCT(ISTEXT(Nuna1)+ISNUMBER(Nuna1))>0
this example checks C9:C18 to see if it contains a value gives True or FalseEach Range for example in Row C20 Nuna1, D20 Nuna2 up to P20 Nuna14.
The same format is used for the other groups as it moves down the page.
Verm1 to Verm14, Mitch1 to Mitch14, Black1 to Black14, Boxh1 to Boxh14, Boxhi1 to Boxhi14
I have tried various ways to achieve but as yet have not bee able to master it. If anyone is able to help be most grateful