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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,215,548
Messages
6,125,472
Members
449,231
Latest member
Sham Yousaf

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