VBA Loop - Add sheet

CROY1985

Well-known Member
Joined
Sep 21, 2009
Messages
501
Office Version
  1. 365
Platform
  1. Windows
Hi all

Just need a bit of a pointer with this loop i'm building. For the first instance of "Yes" i want to just use sheets.select (i.e drop whatever sheet(s) are selected), but then use sheets.select false, for the rest.

Code:
For j = 5 To 9


If Sheets("ReportList").Cells(I + 2, j).Value = "Yes" Then
Sheets(Sheets("ReportList").Cells(2, j).Value).Select False
End If


Next j
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Untested, but try
Code:
   If Sheets("ReportList").Cells(i + 2, j).Value = "Yes" Then
      x = x + 1
      If x = 1 Then
         Sheets(Sheets("ReportList").Cells(2, j).Value).Select
      Else
         Sheets(Sheets("ReportList").Cells(2, j).Value).Select False
      End If
   End If
 
Upvote 0
Solution
Untested, but try
Code:
   If Sheets("ReportList").Cells(i + 2, j).Value = "Yes" Then
      x = x + 1
      If x = 1 Then
         Sheets(Sheets("ReportList").Cells(2, j).Value).Select
      Else
         Sheets(Sheets("ReportList").Cells(2, j).Value).Select False
      End If
   End If


Ahh perfect, thank you!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top