If/Then

I

I.P

I wish to move to the next worksheet if the current worksheet has the
text "no" in cell C21.I keep getting the message no "For or Goto" when
I put a If /Then line in the code. All the worksheets are the same
setup.

Dim nm As String
Dim x, y As Integer
Sheets("DontDelete").Select
x = Range("DontDelete!J6").Value
Range("I8").Select
For y = 1 To x
nm = ActiveCell.Value
Sheets(nm).Select
Range("Q2:AD2").Select
Selection.Copy
Sheets("Timesheet").Select
Range("A19").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Sheets("DontDelete").Select
ActiveCell.Offset(1, 0).Activate
Next y
 
B

Bob Phillips

Where did you try to add it and what did you add?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
I

I.P

Bob said:
Where did you try to add it and what did you add?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Hi Bob
Dim nm As String
Dim x, y As Integer
Sheets("DontDelete").Select
x = Range("DontDelete!J6").Value
Range("I8").Select
For y = 1 To x
nm = ActiveCell.Value
Sheets(nm).Select
Range("G21").Select
If ("G21") = No Then
Sheets("DontDelete").Select
Next y
End If
Range("Q2:AD2").Select
Selection.Copy
Sheets("Timesheet").Select
Range("A19").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Sheets("DontDelete").Select
ActiveCell.Offset(1, 0).Activate
Next y

Ps ("DontDelete! I18") down is a list of people each with a identical
worksheet named after them
Thanks
Ian
 
B

Bob Phillips

This seems to work

Dim nm As String
Dim x, y As Integer
x = Sheets("DontDelete").Range("DontDelete!J6").Value
For y = 1 To x
nm = Sheets("DontDelete").Range("I8").Offset(y - 1, 0).Value
If Sheets(nm).Range("G21").Value <> "No" Then
Sheets(nm).Range("Q2:AD2").Copy
Sheets("Timesheet").Select
Range("A19").Offset(y - 1, 0).PasteSpecial _
Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
End If
Next y


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top