PDA

View Full Version : User Input



IanTrout
02-23-2008, 12:59 AM
I was trying to make a simple macro command to color some cells in excel, but i want to input the cell range and color myself.

I tried to create my own form that would contain some a text box for the cell numbers and i copied the generic code generated by the macro and changed the given cells with string type variables and an int for the color itself. I didn't work that well... :)

My guess is that the variables are just from the wrong type... Which type should i use? and is there a better was of doing what i want to?

And on that note, this is my first post, so hi everybody... :hi:

Thanks in advance,
Ian Trout

Bob Phillips
02-23-2008, 01:56 AM
Just use a simple APplication.Inputbox to get the range, and a dialog for the colour.

IanTrout
02-23-2008, 03:35 AM
quite frankly, i really don't know how to use vba that much and i don't really know how to use Application.Inputbox, but thanks for the tip, ill just look it up... :)

any good sites with that kind of info you know of?

mdmackillop
02-23-2008, 04:03 AM
If you want to type it, use an InputBox as suggested. For the option of selecting a range, add a RefEdit box to your form.

Bob Phillips
02-23-2008, 04:08 AM
As simple as



Dim rng As Range

Set rng = Application.InputBox("Select range to colour with the mouse", Type:=8)

rng.Select
Application.Dialogs(xlDialogPatterns).Show