change cell value on text box change

asylum

Board Regular
Joined
Dec 2, 2003
Messages
243
Hi -

I have the below VB on a sheet which forces a page to recalculate itself when a text box is changed.

I am trying to force the value of cell C21 to be 1 when the text box changes also, I added the thrid line but this does not seem to work, this must be very easy, what am i missing?

thanks

Andy

Private Sub TextBox1_Change()
ActiveSheet.Calculate
Range(c21).Value = "1"

End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi Thaks for that, I spotte dthe speech marks, and have also included the sheet name, but it still wont work... perplexing me now, the active sheet calculate bit works but the other doesn't!

Private Sub TextBox1_Change()
ActiveSheet.Calculate
Sheet("lookup").Range("c21").Value = "1"
End Sub
 
Upvote 0
Is the Textbox on the sheet which you are trying to change? I know this may seem like an obvious question, but how do you know the calculate is working but the Range() = 1 isn't?
 
Upvote 0
HI Richard,

Many thanks for the pointer! - that sorted it out nicely, oddly i ha sthe same bit of code on two sheet, but of course the text box was on the other one! I shall go put on my dunces cap!

Cheers

Andy
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,786
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top