Re: specify cell selection in a marco



If you can select the range first, it might make it simpler:

Sub Uppercase()
Dim x as Range
' Loop to cycle through each cell in the specified range.
For Each x In Selection.Cells
' Change the text in the range to uppercase letters.
x.Value = UCase(x.value)
Next
End Sub

chubach wrote:

I found a useful macro online but it only selects cells A1:A5 and I need to
modify it so I can select a range of cells by highlighting them, and then run
the macro. I tried to delete part of the syntax but just get error messages.
The macro I have now is:

Sub Uppercase()
' Loop to cycle through each cell in the specified range.
For Each x In Range("A1:A5")
' Change the text in the range to uppercase letters.
x.Value = UCase(x.value)
Next
End Sub

Can anyone fix this for me?
thanx - chu

--

Dave Peterson
.



Relevant Pages

  • Re: Change lower case to upper case
    ... Sub Uppercase() ... ' Loop to cycle through each cell in the specified range. ... For Each x In Selection ... ' Change the text in the range to uppercase letters. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Damsel Needs Assitance with Proper_Case Macro
    ... Sub Proper_Case ... > ' Loop to cycle through each cell in the specified range. ...
    (microsoft.public.excel.programming)
  • Re: Formula Weirdness - HELP - Solved
    ... I had a sub to do uppercase on the column next to ... Changing the reference to the correct column fixed it. ... >>I place an IF formula in a cell it works perfectly. ...
    (microsoft.public.excel.programming)
  • Re: Macro not working in 2007
    ... Sub Uppercase() ... ' Loop to cycle through each cell in the specified range. ... ' Change the text in the range to uppercase letters. ...
    (microsoft.public.excel.misc)
  • Change cell range to Uppercase
    ... I have found help on websites on converting a cell text to uppercase upon ... Private Sub UpperCaseButton_Click ... Dim LastRow As String ...
    (microsoft.public.excel.programming)