PC Review


Reply
Thread Tools Rate Thread

Check value on another sheet

 
 
=?Utf-8?B?QnJhZA==?=
Guest
Posts: n/a
 
      4th Sep 2007
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 With Quote
 
 
 
 
=?Utf-8?B?YmFybmFiZWw=?=
Guest
Posts: n/a
 
      4th Sep 2007
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

 
Reply With Quote
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      4th Sep 2007
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 With Quote
 
Jim Rech
Guest
Posts: n/a
 
      4th Sep 2007
>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" <(E-Mail Removed)> wrote in message
news:12A1650D-CB91-4C3C-BA7F-(E-Mail Removed)...
| 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 With Quote
 
=?Utf-8?B?QnJhZA==?=
Guest
Posts: n/a
 
      4th Sep 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Activesheet for chart sheet or work sheet =?Utf-8?B?TlNL?= Microsoft Excel Charting 1 17th Jul 2007 09:00 PM
Check if the first sheet is the selected sheet melody Microsoft Excel Programming 3 13th Sep 2006 07:46 PM
Enable check box in protected sheet + group check boxes =?Utf-8?B?RGV4eHRlcnI=?= Microsoft Excel Misc 4 2nd Aug 2006 12:00 PM
how to use sumif function to check date in 1 sheet is < 2 sheet =?Utf-8?B?QmhhcmF0IFNhYm9v?= Microsoft Excel Worksheet Functions 3 30th Dec 2005 07:10 AM
Check changes on a sheet Lorenzo Microsoft Excel Programming 3 7th Aug 2003 10:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:46 AM.