ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ucase 'data type mismatch' (https://www.excelbanter.com/excel-programming/368520-ucase-data-type-mismatch.html)

DKY[_120_]

ucase 'data type mismatch'
 

I'm trying to make my selection uppercase by doing something like this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539


Jim May

ucase 'data type mismatch'
 
Gotta run. But existing code only works on a single-cell narrow your
highlighted-area and retry.
HTH

"DKY" wrote in
message :

I'm trying to make my selection uppercase by doing something like this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539



Gary Keramidas

ucase 'data type mismatch'
 
try this

Option Explicit
Dim cell As Range
Sub test()
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next
End Sub

--


Gary


"DKY" wrote in message
...

I'm trying to make my selection uppercase by doing something like this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY
------------------------------------------------------------------------
DKY's Profile:
http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539




Bob Phillips

ucase 'data type mismatch'
 
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DKY" wrote in message
...

I'm trying to make my selection uppercase by doing something like this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY
------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539




DKY[_121_]

ucase 'data type mismatch'
 

I think that the code only goes through one cell at a time, I'll pos
the code below

Code
-------------------
Option Explicit

Sub HEADER_MAKER()
Dim CELL
Application.ScreenUpdating = False
For Each CELL In Selection
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
CELL.Borders(xlDiagonalDown).LineStyle = xlNone
CELL.Borders(xlDiagonalUp).LineStyle = xlNone
With CELL.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With CELL.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With CELL.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With CELL.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.Name = "Times New Roman"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

' START REPLACE
Selection.Replace What:=" ", Replacement:="_", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
' END REPLACE
' START REPLACE
Selection.Replace What:=".", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
' END REPLACE

'Selection.Value = upper(Selection.Value)

Selection.EntireColumn.AutoFit

Next CELL
End Sub

-------------------

--
DK
-----------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...fo&userid=1451
View this thread: http://www.excelforum.com/showthread.php?threadid=56553


Tom Ogilvy

ucase 'data type mismatch'
 
If selection.TypeName = "Range" then
if selection.Count = 1 then
if not iserror(selection) then
selection.Value = ucase(selection.Value)
end if
end if
end if

--
Regards,
Tom Ogilvy


"DKY" wrote:


I'm trying to make my selection uppercase by doing something like this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539



DKY[_122_]

ucase 'data type mismatch'
 

That's perfect!!

Not Selection.value but CELL.value, that makes sense.

Bob Phillips Wrote:
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DKY" wrote in
message
...

I'm trying to make my selection uppercase by doing something like

this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY

------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread:

http://www.excelforum.com/showthread...hreadid=565539



--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539


DKY[_123_]

ucase 'data type mismatch'
 

That's perfect!!

Not Selection.value but CELL.value, that makes sense.

Bob Phillips Wrote:
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DKY" wrote in
message
...

I'm trying to make my selection uppercase by doing something like

this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY

------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread:

http://www.excelforum.com/showthread...hreadid=565539



--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539


Bob Phillips

ucase 'data type mismatch'
 
Yes, but cell is just an object name that I chose (it kinda makes sense). It
could as easily be

For Each sausage In Selection
sausage.Value = UCase(sausage.Value)
Next sausage

that variable is just used to refer to each item in the collection (of
selected cells here)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DKY" wrote in message
...

That's perfect!!

Not Selection.value but CELL.value, that makes sense.

Bob Phillips Wrote:
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DKY" wrote in
message
...

I'm trying to make my selection uppercase by doing something like

this.

Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY

------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread:

http://www.excelforum.com/showthread...hreadid=565539



--
DKY
------------------------------------------------------------------------
DKY's Profile:

http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=565539




Jim May

ucase 'data type mismatch'
 
Bob:
Great !! -- I now grasp the full concept of "For Each ..." through
this illustration -- keep such 'em coming.
Jim May


"Bob Phillips" wrote in message
:

Yes, but cell is just an object name that I chose (it kinda makes sense). It
could as easily be

For Each sausage In Selection
sausage.Value = UCase(sausage.Value)
Next sausage

that variable is just used to refer to each item in the collection (of
selected cells here)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DKY" wrote in message
...


That's perfect!!

Not Selection.value but CELL.value, that makes sense.

Bob Phillips Wrote:


For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DKY" wrote in
message
...



I'm trying to make my selection uppercase by doing something like


this.



Selection.Value = ucase(Selection.Value)

and it keeps giving me a data type mismatch error. What am I doing
wrong here?


--
DKY


------------------------------------------------------------------------


DKY's Profile:


http://www.excelforum.com/member.php...o&userid=14515


View this thread:


http://www.excelforum.com/showthread...hreadid=565539






--
DKY
------------------------------------------------------------------------
DKY's Profile:


http://www.excelforum.com/member.php...o&userid=14515

View this thread: http://www.excelforum.com/showthread...hreadid=565539




All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com