[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Re: select a range with a dialog box

Bob Phillips

12/12/2006 3:32:00 PM

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" <DaveF@discussions.microsoft.com> wrote in message
news:B392DF9C-C068-45A4-9C99-134FB0FB524B@microsoft.com...
>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.


1 Answer

DaveF

12/12/2006 3:37:00 PM

0

That was easy.

Thanks.
--
Brevity is the soul of wit.


"Bob Phillips" wrote:

> 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" <DaveF@discussions.microsoft.com> wrote in message
> news:B392DF9C-C068-45A4-9C99-134FB0FB524B@microsoft.com...
> >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.
>
>
>