RadheyaMansel
New Member
- Joined
- Oct 25, 2017
- Messages
- 6
Hi guys,
This is a very simple code, but I'm not sure why it isn't working.
I want to loop through each worksheet in a workbook and make the same change to each: Copy a range and paste the figures into the first available empty row starting in Column C.
At the moment, when I play this Macro there aren't any errors, it just loads for about a minute but when I check the sheets after it's finished, nothing has happened.
Note: I have a macro that just selects all the sheets as a group, and makes the change, but the problem is that it doesn't past the value in the last available row if they are different for each sheet, it seems to find the furthest down free row and then paste into that for all of the sheets.
A little help would be great,
Thank you!
This is a very simple code, but I'm not sure why it isn't working.
I want to loop through each worksheet in a workbook and make the same change to each: Copy a range and paste the figures into the first available empty row starting in Column C.
At the moment, when I play this Macro there aren't any errors, it just loads for about a minute but when I check the sheets after it's finished, nothing has happened.
Note: I have a macro that just selects all the sheets as a group, and makes the change, but the problem is that it doesn't past the value in the last available row if they are different for each sheet, it seems to find the furthest down free row and then paste into that for all of the sheets.
A little help would be great,
Thank you!
Code:
Sub WorksheetLoop()
Application.ScreenUpdating = False
' Declare Current as a worksheet object variable.
Dim wks As Worksheet
Dim Loc As Long
' Loop through all of the worksheets in the active workbook.
For Each wks In Worksheets
'Exclude the named sheets below, coupled with End IF
If wks.Name <> "Ing_Index" And wks.Name <> "Daily Production" And wks.Name <> "StoreToDecanting" Then
Range("H20:J20").Select
Selection.Copy
Loc = Range("C" & Rows.Count).End(xlUp).Row + 1
Range("C" & Loc).PasteSpecial xlPasteValues
End If
Next wks
Application.ScreenUpdating = True
End Sub
[\Code]