Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 69
Default What is wrong with this vba piece of code?

Hi,

I am getting this error: "Object variable or With block variable is
not set!" Here is the mcro's code:

Sub Solve()

Dim SCell As Range

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

Thanks,
Jo

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default What is wrong with this vba piece of code?


It might help if you tell us what you are trying to do?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jo" wrote in message
oups.com...
Hi,

I am getting this error: "Object variable or With block variable is
not set!" Here is the mcro's code:

Sub Solve()

Dim SCell As Range

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

Thanks,
Jo


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default What is wrong with this vba piece of code?

You've declared a range variable but did not assign it a range

Use something like this, substituting the correct range where I have
"Cell_Address_Here_As_String":

Set SCell = Range("Cell_Address_Here_As_String")
--
Kevin Backmann


"Jo" wrote:

Hi,

I am getting this error: "Object variable or With block variable is
not set!" Here is the mcro's code:

Sub Solve()

Dim SCell As Range

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

Thanks,
Jo


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 69
Default What is wrong with this vba piece of code?

On Oct 4, 9:30 am, "Don Guillett" wrote:
It might help if you tell us what you are trying to do?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Jo" wrote in message

oups.com...



Hi,


I am getting this error: "Object variable or With block variable is
not set!" Here is the mcro's code:


Sub Solve()


Dim SCell As Range


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


Thanks,
Jo- Hide quoted text -


- Show quoted text -


Say I have two cells A1 and A2. In A1, I have a random number built
into a formula. In A2, I have a formula like this "if(A15,1,0)".

Now, I am creating a Macro that will keep A1 running till its value is
5 where it stops.


So, how can I make the above code runs?

Thanks,
Jo

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default What is wrong with this vba piece of code?

Kevin has responded to your original question... I just wanted to make a
brief comment about your code. You do not need the If-Then test inside your
loop. The

Do Until SCell.Value = 1

statement won't let the loop execute if SCell.Value equals 1, so there is no
need to see if it equals 1 inside the loop itself. If you think it might be
clearer to you, you can change the Do loop statement to this instead...

Do While SCell.Value < 1

which looks like the If-Then test you were performing originally (you still
would not need the If-Then test within your loop).

Rick


"Jo" wrote in message
oups.com...
Hi,

I am getting this error: "Object variable or With block variable is
not set!" Here is the mcro's code:

Sub Solve()

Dim SCell As Range

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

Thanks,
Jo


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
What is wrong with the code? Eric Excel Discussion (Misc queries) 2 September 13th 07 10:36 AM
Add chart - what is wrong with the code? tskogstrom Charts and Charting in Excel 3 October 24th 06 05:22 PM
Can someone tell me what is wrong with this code? Ant Excel Discussion (Misc queries) 8 November 14th 05 02:53 PM
Need to "not show" piece of line in graph Callan Charts and Charting in Excel 5 October 8th 05 03:42 AM
What's wrong with my code ? christophe meresse Excel Worksheet Functions 3 August 2nd 05 05:09 PM


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