473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

For Loop Not Catching All Sheets

This code is meant to iterate over all of my sheets, but it is skipping some. Can anyone help me figure out why?

Expand|Select|Wrap|Line Numbers
  1. Sub BuildIntegration()
  2.  
  3. 'Setup Variables
  4.  
  5.     Dim NextRow As Integer
  6.     Dim intSheet As Integer
  7.     Dim WkshCount As Integer
  8.  
  9.     WkshCount = ActiveWorkbook.Worksheets.Count
  10.  
  11. 'Turn off screen refresh
  12.  
  13.     'Application.ScreenUpdating = False
  14.  
  15. 'Select first sheet of workbook
  16.  
  17.     Sheet1.Select
  18.  
  19.  
  20. 'Unhide Cells
  21.  
  22.     For intSheet = 0 To WkshCount - 1
  23.  
  24.         intSheet = intSheet + 1
  25.         Sheets(intSheet).Select
  26.         Columns("K:X").Select
  27.         Selection.EntireColumn.Hidden = False
  28.         'MsgBox "continue..."
  29.     Next intSheet
May 29 '14 #1

✓ answered by Luk3r

I don't think this line is necessary when doing a loop from zero to a count:

Expand|Select|Wrap|Line Numbers
  1. intSheet = intSheet + 1
I assume that your program is actually skipping every other sheet.

3 1491
Luk3r
300 256MB
I don't think this line is necessary when doing a loop from zero to a count:

Expand|Select|Wrap|Line Numbers
  1. intSheet = intSheet + 1
I assume that your program is actually skipping every other sheet.
May 29 '14 #2
Thank you! After posting - I dug in deeper and realized that it was skipping every other. Then the fix was apparent. When I posted it seemed like it was random sheets.
May 29 '14 #3
Luk3r
300 256MB
Glad you got it figured out without me even though we landed on the same answer. :)
May 29 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Osiris Sawiris | last post by:
I inherited an Inventory control application that updates the stock from the branches at the end of each day. We receive the stock transactions via e-mail attachments (Excel Sheets). Those...
3
by: boaring | last post by:
I need to use Macro's in Excel and always the same changes to 31 Sheets. (31 days in the Month). I'm trying to use a FOR loop but cannot get the correct format to have the sheet number to increment...
1
by: ChrisDChow | last post by:
Hi there, I need help with Visual Basic. I am trying to use a variable to select different sheets Example : I would like to have this formula in Cells A1 of my summary sheet ...
3
by: Robert Inder | last post by:
I am struggling to catch kestrokes within an Internet Explorer 6 window. My window happens to be displaying three frames, though I suspect a similar problem would arise with a single document. ...
1
by: markwood2k | last post by:
Hi all, I'm in over my head. The middle part below ( My recorded macro) works fine, but I'd like some help making it loop. can you help? For each office (name1, name2, name3 ...) ...
4
by: Harshe | last post by:
hello all, I am trying to code, but i am just stuck after importing one sheet. so here is the gist of what i need help with. In a workbook at the start of the year (january) i will have 4...
2
wassup
by: wassup | last post by:
Hey Guys, Good Morning. I have probelm here. I have 2 workbooks, 1 is Master.xls (my format to collect all the data), another 1 is Machine.xls (data collect from). Inside...
0
by: damiencarr | last post by:
i have a spreadsheet/worksheet called "NTH_Alliance" containing rows of related data grouped together under different headings, that are named as different weeks (e.g. Week 5 (26/01/2009 -...
3
by: ranjcar | last post by:
I have recorded a Macro on Excel 2007 to sort a column of 912 counts into its constituents. I am a VBA beginner and have tried to set up a loop. I have not succeeded over the last few days. Please...
2
by: sasen903 | last post by:
private String GetExcelSheetNames(string excelFile) { OleDbConnection objConn = null; SqlConnection objSqlConn = null; ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.