ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a more elegant way to macro this? (https://www.excelbanter.com/excel-programming/387308-there-more-elegant-way-macro.html)

Brad

Is there a more elegant way to macro this?
 
Sub changekey()
If Range("b1").Value = "Joint" Then
Range("key1").Value = "J" & Mid(Range("key1").Value, 2, 255)
End If
End Sub

Tim

Is there a more elegant way to macro this?
 
Maybe not more elegant, but it would be more robust if you qualify all
appropriate Range's with a sheet reference.

Tim

"Brad" wrote in message
...
Sub changekey()
If Range("b1").Value = "Joint" Then
Range("key1").Value = "J" & Mid(Range("key1").Value, 2, 255)
End If
End Sub




NickHK

Is there a more elegant way to macro this?
 
Brad,
You can work with the .Characters instead:

Range("key1").Characters(1, 1).Text = "J"

NickHK

"Brad" wrote in message
...
Sub changekey()
If Range("b1").Value = "Joint" Then
Range("key1").Value = "J" & Mid(Range("key1").Value, 2, 255)
End If
End Sub




Brad

Is there a more elegant way to macro this?
 
Thank you

"NickHK" wrote:

Brad,
You can work with the .Characters instead:

Range("key1").Characters(1, 1).Text = "J"

NickHK

"Brad" wrote in message
...
Sub changekey()
If Range("b1").Value = "Joint" Then
Range("key1").Value = "J" & Mid(Range("key1").Value, 2, 255)
End If
End Sub






All times are GMT +1. The time now is 10:06 PM.

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