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 to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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