Hi there,
I have a macro that (created with help from this form) worked fine for what i intend it to do, but later on i came to find that it needs to have a check to be performed on a cell value being empty or not before running the whole program. So, now when i tried to insert an IF condition its not taking it...being new to vba coding i do not understand what or why its saying that error message. Can someone help me write this piece of code, correctly?
thanks in advance!
Here is my code:
Sub Populating_Summary_Sheet()
Application.ScreenUpdating = False
Dim s1 As Excel.Worksheet
Dim s2 As Excel.Worksheet
Dim iLastCellS2 As Excel.Range
Dim iLastRowS1 As Long
Dim Cnt As Long
Dim LstSht As String
LstSht = InputBox("Please enter the last sheet number, like 103")
If LstSht = "" Then Exit Sub
Set s2 = Sheets("Summary")
For Cnt = 2 To CLng(LstSht)
Set s1 = Sheets(CStr(Cnt))
If Range("C28") = "" Then GoTo JUMP
Else ' -->do the below, and i unable to get this done right.
iLastRowS1 = s1.Cells(s1.Rows.Count, "C").End(xlUp).Row
Set iLastCellS2 = s2.Cells(s2.Rows.Count, "N").End(xlUp).Offset(1, 0)
s1.Range("B28:C" & iLastRowS1).Copy
iLastCellS2.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False
s1.Range("F28:H" & iLastRowS1).Copy
iLastCellS2.Offset(0, 5).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False
JUMP:
Next Cnt
I have a macro that (created with help from this form) worked fine for what i intend it to do, but later on i came to find that it needs to have a check to be performed on a cell value being empty or not before running the whole program. So, now when i tried to insert an IF condition its not taking it...being new to vba coding i do not understand what or why its saying that error message. Can someone help me write this piece of code, correctly?
thanks in advance!
Here is my code:
Sub Populating_Summary_Sheet()
Application.ScreenUpdating = False
Dim s1 As Excel.Worksheet
Dim s2 As Excel.Worksheet
Dim iLastCellS2 As Excel.Range
Dim iLastRowS1 As Long
Dim Cnt As Long
Dim LstSht As String
LstSht = InputBox("Please enter the last sheet number, like 103")
If LstSht = "" Then Exit Sub
Set s2 = Sheets("Summary")
For Cnt = 2 To CLng(LstSht)
Set s1 = Sheets(CStr(Cnt))
If Range("C28") = "" Then GoTo JUMP
Else ' -->do the below, and i unable to get this done right.
iLastRowS1 = s1.Cells(s1.Rows.Count, "C").End(xlUp).Row
Set iLastCellS2 = s2.Cells(s2.Rows.Count, "N").End(xlUp).Offset(1, 0)
s1.Range("B28:C" & iLastRowS1).Copy
iLastCellS2.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False
s1.Range("F28:H" & iLastRowS1).Copy
iLastCellS2.Offset(0, 5).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False
JUMP:
Next Cnt