![]() |
If/Then
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 |
If/Then
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.P" wrote in message ups.com... 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 |
If/Then
Bob Phillips wrote:
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.P" wrote in message ups.com... I wish to move to the next worksheet if the current worksheet has the text "no" in cell G21.I keep getting the message no "For or Goto" when I put a If /Then line in the code. 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 |
If/Then
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) "I.P" wrote in message ups.com... Bob Phillips wrote: 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.P" wrote in message ups.com... I wish to move to the next worksheet if the current worksheet has the text "no" in cell G21.I keep getting the message no "For or Goto" when I put a If /Then line in the code. 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 |
All times are GMT +1. The time now is 10:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com