View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 1,726
Default select a range with a dialog box

Sub UPPERFirst3()
Dim myRange as Range
Dim myCell As Range

set myRange= Application.Inputbox("Select range with mouse",Type:=8)
For Each myCell In myRange
myCell.Value = UCase(Left(myCell.Value, 3)) & Mid(myCell.Value, 4,
Len(myCell.Value) - 3)
Next myCell
End Sub

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Dave F" wrote in message
...
I have the following macro which capitalizes the first three characters in
each cell of a selected range:

Sub UPPERFirst3()
Dim myCell As Range

For Each myCell In Selection
myCell.Value = UCase(Left(myCell.Value, 3)) & Mid(myCell.Value, 4,
Len(myCell.Value) - 3)
Next myCell
End Sub

I've attached this macro to a button.

What I would like to do is modify this code so that when you click the
button, a dialog box pops up which asks you to enter the range (say
A1:A10000). Then when you click OK the rest of the macro (i.e., what I
pasted above) would iterate through the range.

How do I do this? Do I use InputBox? MsgBox?

Thanks,

Dave
--
Brevity is the soul of wit.