LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Random glitch?

Hello, all.

This issue is a bit complicated, but I'll try to be as clear (yet brief) as
possible.

I have an audit workbook which contains 18 sections of audit questions on
four worksheets (called 1 thru 6, 7 thru 11, 12 thru 15 and 16 thru 18).
Each section contains a varying number of questions, and the workbook can
contain audit data for up to 20 audited facilities. Some of the facilities
are laboratories.

I have programmed a checkbox which sits next to each facility name on the
title sheet of the audit workbook. If the facility is a laboratory and the
user clicks the checkbox, the code will go through the workbook and, for that
particular facility, mark all of the line items which do NOT apply to
laboratories as "Not Applicable" (if a section header) and "N/A" (if an
individual question).

At least that's what is supposed to happen.

What I'm noticing is that sometimes it appears to work and sometimes it
doesn't. I would appreciate it if someone would review the code below and
see if you spot anything glaringly wrong.

Sub RDNAPop(FACVal)
'
'Called by one of 20 checkboxes. FACVal corresponds to a particular column
on each of the four worksheets. One column represents one facility.
'
Dim GAW As Object
Application.ScreenUpdating = False
For J = 1 To 4
If J = 1 Then Set GAW = ActiveWorkbook.Sheets("1 thru 6")
If J = 2 Then Set GAW = ActiveWorkbook.Sheets("7 thru 11")
If J = 3 Then Set GAW = ActiveWorkbook.Sheets("12 thru 15")
If J = 4 Then Set GAW = ActiveWorkbook.Sheets("16 thru 18")

For ROWID = 6 To GAW.Range("I4") + 5 'formula in cell I4 in each of the
four worksheets which tells VBA how many rows there are in each worksheet

If GAW.Cells(ROWID, 5) < "" Then 'skip over any rows in which column E
is blank. These rows are for questions to be added later.

Set c = GAW.Cells(ROWID, 5).Find("LAB", LookIn:=xlValues) 'Look for
the three-letter combination LAB in column E. If LAB is there, the question
applies to a lab and the row should be skipped. (NOTE: The cell will
contain other text besides "LAB", which is why I used a .Find rather than If
GAW.Cells(ROWID, 5)="LAB")

If c Is Nothing And GAW.Cells(ROWID, 2) = "" Then GAW.Cells(ROWID,
FACVal) = "Not Applicable" 'If LAB is NOT found and column B is blank, this
is a header row, so put in "Not Applicable"

If c Is Nothing And GAW.Cells(ROWID, 2) < "" Then GAW.Cells(ROWID,
FACVal) = "N/A" 'If LAB is NOT found and column B is NOT blank, this is a
question row, so put in "N/A"

End If

Next ROWID 'go to the next row in the worksheet

Next J 'Go to the next worksheet
Application.ScreenUpdating = True
Set GAW = Nothing
End Sub

There are no problems with data being put into the correct column, so that's
not an issue.

The problem is that when LAB appears in a header row or question row, it's
hit and miss as to whether "Not Applicable" or "N/A" are entered by the code.
As I said, sometimes it works and sometimes it doesn't.

All I'm asking for is for someone to review the code above and let me know
if you think it should do what I explained it should do.

Any ideas/help would be appreciated.

Thanks,
MARTY
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste Special Glitch Lady Success Excel Worksheet Functions 1 June 23rd 09 11:45 PM
sheet dragging glitch? Spheon Excel Discussion (Misc queries) 1 November 20th 07 09:24 AM
vlookup glitch Marlene Excel Worksheet Functions 3 July 10th 07 04:50 PM
Another odd VBA glitch in 2007 teepee Excel Discussion (Misc queries) 4 April 1st 07 09:16 PM
Offset Glitch Arturo Excel Programming 2 February 24th 05 11:18 PM


All times are GMT +1. The time now is 10:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"