Can't use uppercase - type mismatch

DonAndress

Active Member
Joined
Sep 25, 2011
Messages
362
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hello.

I'd like to use such a simple code but I get Type mismatch error.
In this example "lastFund" returns 32. It doesn't matter if I put 32 instead of "lastFund".
This code passes if I make a reference to one cell only instead of a range.
Code:
Range(Cells(14, 4), Cells(lastFund, 4)) = UCase(Range(Cells(14, 4), Cells(lastFund, 4)))
Where do I go wrong?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Ucase can only evaluate a single cell at a time.
You'd have to loop through the range, and do them 1 at a time.
Code:
For Each c In Range(....)
    c.Value = UCase(c.Value)
Next c
 
Upvote 0
Maybe...

Code:
With Range(Cells(14, 4), Cells(lastFund, 4))
        .Value = Evaluate("=IF(Row(),UPPER(" & .Address & "))")
End With

M.
 
Upvote 0
Maybe...

Code:
With Range(Cells(14, 4), Cells(lastFund, 4))
        .Value = Evaluate("=IF(Row(),UPPER(" & .Address & "))")
End With
Evaluate... "Yes!"... a man after my own heart.:LOL:

One point... you can save a character by eliminating the equal sign... unlike assigning a formula to the Formula property of a range, the Evaluate function does not need the leading equal sign to know it has received a formula to evaluate.
 
Upvote 0
Upvote 0
Good God, Marcelo and Rick.
That's sofisticated for me ;)
I wanted to avoid looping and now I need a minute to understand this code.
But thank you very much!
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

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