Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Check value on another sheet

Thanks for taking the time to read my question.

I have 2 sheets and am on the first one. The Second one "qcust" has my data
on it and I want to go through it row by row until there is no data left.

Why can't I do this? It gives me an application error

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""

Here is the full code.

Sub MergeAndPrint()
Dim TheRow As Integer

TheRow = 2

Worksheets("qcust").Select

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""
Range("D3") = Sheets("qcust").Cells(TheRow, 2).Value
Range("D4") = Sheets("qcust").Cells(TheRow, 3).Value
Range("D8") = Sheets("qcust").Cells(TheRow, 1).Value

TheRow = TheRow + 1
Loop

MsgBox "Complete"

End Sub

Thanks,

Brad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Check value on another sheet

3 things,
1) TheCol is never set so it is checking Column 0 which is invalid
2) You don't want to select the "qcust" sheet
3) TheRow should be a long. There may not be 32,000 rows but it is a good
habit to make row index varialbles longs.

Peter Richardson

"Brad" wrote:

Thanks for taking the time to read my question.

I have 2 sheets and am on the first one. The Second one "qcust" has my data
on it and I want to go through it row by row until there is no data left.

Why can't I do this? It gives me an application error

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""

Here is the full code.

Sub MergeAndPrint()
Dim TheRow As Integer

TheRow = 2

Worksheets("qcust").Select

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""
Range("D3") = Sheets("qcust").Cells(TheRow, 2).Value
Range("D4") = Sheets("qcust").Cells(TheRow, 3).Value
Range("D8") = Sheets("qcust").Cells(TheRow, 1).Value

TheRow = TheRow + 1
Loop

MsgBox "Complete"

End Sub

Thanks,

Brad

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Check value on another sheet

Brad,

The variable TheCol is not defined/initialized. Try:

Do Until Worksheets("qcust").Cells(TheRow, 1) = ""



--
Hope that helps.

Vergel Adriano


"Brad" wrote:

Thanks for taking the time to read my question.

I have 2 sheets and am on the first one. The Second one "qcust" has my data
on it and I want to go through it row by row until there is no data left.

Why can't I do this? It gives me an application error

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""

Here is the full code.

Sub MergeAndPrint()
Dim TheRow As Integer

TheRow = 2

Worksheets("qcust").Select

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""
Range("D3") = Sheets("qcust").Cells(TheRow, 2).Value
Range("D4") = Sheets("qcust").Cells(TheRow, 3).Value
Range("D8") = Sheets("qcust").Cells(TheRow, 1).Value

TheRow = TheRow + 1
Loop

MsgBox "Complete"

End Sub

Thanks,

Brad

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Check value on another sheet

It gives me an application error

Always good to be very specific (the text of the error message, not just its
number)

Have you set a value for TheCol? If not it's 0 which is not a valid column
number.

--
Jim
"Brad" wrote in message
...
| Thanks for taking the time to read my question.
|
| I have 2 sheets and am on the first one. The Second one "qcust" has my
data
| on it and I want to go through it row by row until there is no data left.
|
| Why can't I do this? It gives me an application error
|
| Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""
|
| Here is the full code.
|
| Sub MergeAndPrint()
| Dim TheRow As Integer
|
| TheRow = 2
|
| Worksheets("qcust").Select
|
| Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""
| Range("D3") = Sheets("qcust").Cells(TheRow, 2).Value
| Range("D4") = Sheets("qcust").Cells(TheRow, 3).Value
| Range("D8") = Sheets("qcust").Cells(TheRow, 1).Value
|
| TheRow = TheRow + 1
| Loop
|
| MsgBox "Complete"
|
| End Sub
|
| Thanks,
|
| Brad


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Check value on another sheet

Thanks Vergel,

Sometimes another set of eyes helps. I thought I got rid of all of those.

Thanks again,

Brad

"Vergel Adriano" wrote:

Brad,

The variable TheCol is not defined/initialized. Try:

Do Until Worksheets("qcust").Cells(TheRow, 1) = ""



--
Hope that helps.

Vergel Adriano


"Brad" wrote:

Thanks for taking the time to read my question.

I have 2 sheets and am on the first one. The Second one "qcust" has my data
on it and I want to go through it row by row until there is no data left.

Why can't I do this? It gives me an application error

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""

Here is the full code.

Sub MergeAndPrint()
Dim TheRow As Integer

TheRow = 2

Worksheets("qcust").Select

Do Until Worksheets("qcust").Cells(TheRow, TheCol) = ""
Range("D3") = Sheets("qcust").Cells(TheRow, 2).Value
Range("D4") = Sheets("qcust").Cells(TheRow, 3).Value
Range("D8") = Sheets("qcust").Cells(TheRow, 1).Value

TheRow = TheRow + 1
Loop

MsgBox "Complete"

End Sub

Thanks,

Brad

Reply
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
Check Activesheet for chart sheet or work sheet NSK Charts and Charting in Excel 1 July 17th 07 09:00 PM
Check for Sheet Troubled User Excel Programming 7 May 8th 07 12:40 AM
Check if the first sheet is the selected sheet melody Excel Programming 3 September 13th 06 07:46 PM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM
how to use sumif function to check date in 1 sheet is < 2 sheet Bharat Saboo Excel Worksheet Functions 3 December 30th 05 07:10 AM


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

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

About Us

"It's about Microsoft Excel"