inputform and activecell IF function problem

mattchoo87

New Member
Joined
Sep 3, 2014
Messages
3
Hi all, I'm very new to VBA but trying my hand at my first form. I've searched for a couple of hours an can't seem to fix this so here I am....

What I have done so far is create a form with a textboxes which relates to an upper limit for which I want to base my changes in the active cell.

I have the form initialize with

MAMtext.Value = 1


Then, I take some data in column A and run a text to columns on it via the userform macro OK button

Next step is to take that textbox value (1) and use it to see if my activecell is greater than it starting at C4:

Range("C4").Select

Do While ActiveCell.Value <> ""
If ActiveCell.Value > MAMtext.Value Then ActiveCell.Value = "DETSAT"
ActiveCell.Offset(1, 0).Select
Loop


and so on until all values above 1 have been changed to DETSAT.

When I step in the macro, everything looks fine (MAMtext.Value displays as "1" though?), but it doesn't then change my activecell to DETSAT as the loop cycles...

When I try the line in the immediate window it seems to work fine.

What am I missing? I'm sure it is something simple!

Thanks in advance!

Matt
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Welcome to board Matt
Try converting your value to an integer like this
Code:
Int(MAMtext.value)
HTH
 
Upvote 0
it works! thanks!

For future reference next question will then be... How do you use a TextBox for entering numbers as integers (or even decimals) by default?

Thanks heaps for the help!
 
Upvote 0
FYI all, i used Cdec(expression) as sometimes the values will be a decimal.

still frustrating I have to do that though... surely theres a setting somewhere for the textbox to input as a decimal anyway?
 
Upvote 0
it works! thanks!

For future reference next question will then be... How do you use a TextBox for entering numbers as integers (or even decimals) by default?

Thanks heaps for the help!
Absolutely no problem, glad to help.

FYI all, i used Cdec(expression) as sometimes the values will be a decimal.

still frustrating I have to do that though... surely theres a setting somewhere for the textbox to input as a decimal anyway?
Thanks for the feedback. And to the best of my knowledge a textbox will always return a string unless formatted.
 
Upvote 0

Forum statistics

Threads
1,203,212
Messages
6,054,184
Members
444,707
Latest member
cahayagalax

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