Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Simple VBA code questions

Hi everyone,

I have thise short piece of code (Macro):

Dim SCell As Range
If SCell.Value < 1 Then
Range("J24").Select
Calculate
ElseIf SCell = 1 Then
End If

where "SCell" is name of a cell. I want to keep running till SCell is
"1". I know it needs a do-loop kind of thing. Anyhelp would be greatly
appreciated.

Thanks,
Jo

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Simple VBA code questions

Dim SCell As Range
RowCount = 1
do while cells(RowCount,"J").value < 1
RowCount = RowCount + 1
loop


"Jo" wrote:

Hi everyone,

I have thise short piece of code (Macro):

Dim SCell As Range
If SCell.Value < 1 Then
Range("J24").Select
Calculate
ElseIf SCell = 1 Then
End If

where "SCell" is name of a cell. I want to keep running till SCell is
"1". I know it needs a do-loop kind of thing. Anyhelp would be greatly
appreciated.

Thanks,
Jo


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Simple VBA code questions

On Oct 3, 3:37 pm, Joel wrote:
Dim SCell As Range
RowCount = 1
do while cells(RowCount,"J").value < 1
RowCount = RowCount + 1
loop



"Jo" wrote:
Hi everyone,


I have thise short piece of code (Macro):


Dim SCell As Range
If SCell.Value < 1 Then
Range("J24").Select
Calculate
ElseIf SCell = 1 Then
End If


where "SCell" is name of a cell. I want to keep running till SCell is
"1". I know it needs a do-loop kind of thing. Anyhelp would be greatly
appreciated.


Thanks,
Jo- Hide quoted text -


- Show quoted text -


SCell is defined but never used in your version?!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Simple VBA code questions

The problem with putting this in a loop is
that if your calculation never puts the value
of SCell to 1, the loop will run infinitely or
until you get a memory overflow. However, here
is the loop.

Dim SCell As Range
Do Until SCell.Value = 1
If SCell.Value < 1 Then
Range("J24").Select
Calculate
End If
Loop

You could avoid the continuous loop by making the
Do Until SCell.Value = 1 Or <= 1, depending on
Whether your calcultion runs up or down.

"Jo" wrote:

Hi everyone,

I have thise short piece of code (Macro):

Dim SCell As Range
If SCell.Value < 1 Then
Range("J24").Select
Calculate
ElseIf SCell = 1 Then
End If

where "SCell" is name of a cell. I want to keep running till SCell is
"1". I know it needs a do-loop kind of thing. Anyhelp would be greatly
appreciated.

Thanks,
Jo


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Simple VBA code questions

On Oct 3, 4:34 pm, JLGWhiz wrote:
The problem with putting this in a loop is
that if your calculation never puts the value
of SCell to 1, the loop will run infinitely or
until you get a memory overflow. However, here
is the loop.

Dim SCell As Range
Do Until SCell.Value = 1
If SCell.Value < 1 Then
Range("J24").Select
Calculate
End If
Loop

You could avoid the continuous loop by making the
Do Until SCell.Value = 1 Or <= 1, depending on
Whether your calcultion runs up or down.



"Jo" wrote:
Hi everyone,


I have thise short piece of code (Macro):


Dim SCell As Range
If SCell.Value < 1 Then
Range("J24").Select
Calculate
ElseIf SCell = 1 Then
End If


where "SCell" is name of a cell. I want to keep running till SCell is
"1". I know it needs a do-loop kind of thing. Anyhelp would be greatly
appreciated.


Thanks,
Jo- Hide quoted text -


- Show quoted text -


I am getting this error: "Object variable or With block variable not
set"!?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Simple VBA code questions

Since you Dim the SCell As Range, Somewhere in your code, before you run the
loop, you need to define the SCell:

Set SCell = Worksheets(?).Range(?)

Fill in the ? with your worksheet and range data.

"Jo" wrote:

On Oct 3, 4:34 pm, JLGWhiz wrote:
The problem with putting this in a loop is
that if your calculation never puts the value
of SCell to 1, the loop will run infinitely or
until you get a memory overflow. However, here
is the loop.

Dim SCell As Range
Do Until SCell.Value = 1
If SCell.Value < 1 Then
Range("J24").Select
Calculate
End If
Loop

You could avoid the continuous loop by making the
Do Until SCell.Value = 1 Or <= 1, depending on
Whether your calcultion runs up or down.



"Jo" wrote:
Hi everyone,


I have thise short piece of code (Macro):


Dim SCell As Range
If SCell.Value < 1 Then
Range("J24").Select
Calculate
ElseIf SCell = 1 Then
End If


where "SCell" is name of a cell. I want to keep running till SCell is
"1". I know it needs a do-loop kind of thing. Anyhelp would be greatly
appreciated.


Thanks,
Jo- Hide quoted text -


- Show quoted text -


I am getting this error: "Object variable or With block variable not
set"!?


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
Questions should be simple please help babiigirl Excel Worksheet Functions 3 June 14th 06 07:24 PM
two very simple questions filo666 Excel Programming 9 December 27th 05 03:08 PM
VB simple questions Ch Excel Programming 1 August 5th 05 06:18 AM
Two (probably) simple questions, but not for me.... Candee[_34_] Excel Programming 1 June 14th 05 06:51 PM
Several simple questions Stuart[_5_] Excel Programming 1 September 14th 03 08:58 PM


All times are GMT +1. The time now is 08:09 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"