Oct 26 2022 05:19 AM
Tried a VBA for copying specific cells from each worksheet and appending the data in one worksheet ("Comb") which is working as my requirement. But I understand that the code runs all the worksheet including the one which I assigned for copying and appending the data from other sheets. I need to exclude the "Comb" worksheet (as I am appending the data in this worksheet) and only run the code in other worksheets. If so how the code should be updated.
I appreciate if someone can give suggession to make the code better
Sub Copydatamod()
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Worksheets
Sh.Range("B7:EA46").Copy
Sheets("Comb").Activate
Range("B" & Rows.Count).End(xlUp).Rows.Cells.Offset(2, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next Sh
End Sub
(Please guide if the last row selection and paste can be combined)
Oct 26 2022 05:40 AM
SolutionSub Copydatamod()
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Worksheets
Select Case Sh.Name
Case Is = "Comb"
Case Else
Sh.Range("B7:EA46").Copy
Sheets("Comb").Activate
Range("B" & Rows.Count).End(xlUp).Rows.Cells.Offset(2, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Select
Next Sh
End Sub
Maybe with a SELECT CASE statement.
Oct 26 2022 06:38 AM
Oct 26 2022 07:32 AM
You are welcome. Sorry i don't know if it's possible to combine rows 11 and 12.
Oct 26 2022 05:40 AM
SolutionSub Copydatamod()
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Worksheets
Select Case Sh.Name
Case Is = "Comb"
Case Else
Sh.Range("B7:EA46").Copy
Sheets("Comb").Activate
Range("B" & Rows.Count).End(xlUp).Rows.Cells.Offset(2, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Select
Next Sh
End Sub
Maybe with a SELECT CASE statement.