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: 23
Default blank value for row and column in msgbox

Hi;

I'm trying to get some code working that inspects information on one sheet
called "data" and displays any matches in the other sheet called "result".
The result sheet is split into two areas: search criteria and results. When a
submit button is clicked after criteria is entered in the cells, matching
rows in the data sheet will be displayed in the results area of the "result"
sheet. I set some variables as follows:

Dim MyRow As Integer, MyCol As Integer
Dim CritRow As Integer, CritRng As String, RightCol As Integer
Dim TopRow As Integer, BottomRow As Integer, LeftCol As Integer

DataRng = "A2:H2" ' range of column headers for Data table
CritRng = "B3:I5" ' range of cells for Criteria table
ResultsRng = "B8:I8"
LeftCol = Range(ResultsRng).Column
RightCol = LeftCol + Range(ResultsRng).Columns.Count - 1

When the following code is executed, the value of TopRow is blank.

TopRow = Worksheets("Data").Range(DataRng).Row
MsgBox "TopRow= ", TopRow

Likewise, the following code shows blanks for the values of MyCol and MyRow.

For MyRow = TopRow + 1 To BottomRow
MsgBox "MyRow=", MyRow
For MyCol = LeftCol To RightCol
MsgBox "MyCol=", MyCol
MsgBox "Cells(MyRow,MyCol).Value=", Cells(MyRow, MyCol).Value
If Cells(MyRow, MyCol).Value < "" Then CritRow = MyRow
Next
Next

As a result, the CritRow is always 0 so the following else clause is never
executed.

If CritRow = 0 Then
MsgBox "No Criteria detected"
Else
CritRng = Range(Cells(TopRow, LeftCol), Cells(CritRow, RightCol)).Address

The Data sheet is filled with information. so I'm at a loss as to why I'm
getting blank values. Any help is greatly appreciated.
--
JJFJR
 
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
insert a blank column between each column in a data file Holly Excel Discussion (Misc queries) 1 October 31st 07 07:04 PM
How do I count the items in one column if another column is blank dereksmom Excel Worksheet Functions 1 November 8th 06 11:34 PM
Warning message if one column contains any text and another column is blank Dileep Chandran Excel Worksheet Functions 12 October 30th 06 07:50 PM
VB evaluate a value in a table's column and display msgbox AusTexRich Excel Discussion (Misc queries) 8 October 10th 05 10:23 PM
Populating column N with a formula if column A is Null or Blank Steve Excel Programming 4 September 28th 04 01:50 PM


All times are GMT +1. The time now is 11:38 PM.

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"