VBA to set value of a cell
Cheers! I knew i was missing a bit somewhere!
Thanks a lot!
"Tom Ogilvy" wrote:
Private Sub Workbook_Open()
Dim rng As Range, rng2 As Range
With ThisWorkbook
Set rng = .Worksheets("Sheet1").Range("B2")
Set rng2 = .Worksheets("Sheet1").Range("D2")
End with
'Private/Toll'
If lcase(rng.Value) = "shane farley" Then
rng2.Value = "Private"
Else
rng2.Value = "Toll"
End If
End Sub
--
Regards,
Tom Ogilvy
"ivory_kitten" wrote in message
...
Ok, i tried that but it's not working, have i done something wrong?
Private Sub Workbook_Open()
Dim rng As Range, rng2 As Range
Set rng = Me.Range("B2")
Set rng2 = Me.Range("D2")
'Private/Toll'
If rng.Value = "Shane Farley" Then
rng2.Value = "Private"
Else: rng2.Value = "Toll"
End If
End Sub
It gets up to Set rng = Me and then it says Compile error: Method or data
member not found
It highlights .Range
Any ideas?
"JLGWhiz" wrote:
In the VBE clck on ThisWorkbook and use this line for your Sub:
Private Sub Workbook_Open()
' add your code here'
End Sub
"ivory_kitten" wrote:
Thanks, I had that but for some reason it was not working! How can I
set
this so that it does this on open instead of on change?
"JMB" wrote:
If rng3.Value = "Shane" Then
rng5.Value = "Private"
Else: rng5.Value = "Public"
End If
"ivory_kitten" wrote:
I want to set cell D2 (named rng5) to a certain text value if cell
B2 (named
rng3) equals a certain value.
Eg:
If rng3 = Shane then rng5 value to be set to "Private", else rng5
value to
be set to "Public"
Any help appreciated, thanks!
|