Reputation: 43
I have a small issue here. The I want to make only one cell reference edit in this macro, by changing the reference for rcell9-- in this case it is "F2". And I also want to avoid using .Activate. However I want rcell5 to be the value in the cell that rcell9 references. How can I program this differently?
Sub Noname()
Dim rcell5 As String, rcell9 As String
Dim MonthDays As Long
rcell9 = ("F2")
Range(rcell9).Activate
rcell5 = ActiveCell.Value
End Sub
Upvotes: 0
Views: 268
Reputation: 23283
I suggest a few small tweaks:
Sub NoName2()
Dim rCell5 As String, rCell9 As Range
' Dim monthDays As Long ' Why have this?
Set rCell9 = Range("F2")
rCell5 = rCell9.Value
End Sub
While the above should work for you, I've found myself thinking - what's your goal with the sub? The variable names aren't really helpful, and IMO a little confusing. You want a string to get its value from a cell, that's normal. However the naming convention makes the code a little confusing to read, even when it's so short.
I suspect there's a bigger plan here, so just consider what that may be, and I suggest tweaking the variable names to be more in tune with that.
Upvotes: 1