Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy question - If ...then Change cell value
Greetings,
This seems like such an easy question, but I have searched and just cannot find the answer. In my Workbook Open(), I would like to check the value of Q1 and if it = 1, then change the value to = 2. I have tried: If Range("Q39").Value = "1" Then Range("Q39").Value = "2" End If But it errors out... help... Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy question - If ...then Change cell value
Hi Mike,
Your code works fine to me. If anything I would change the "1" and "2" to 1 and 2 and qualify the range with the sheet name, something like this: Private Sub Workbook_Open() With Sheets("Sheet1") If .Range("Q39").Value = 1 Then .Range("Q39").Value = 2 End If End With End Sub Regards, KL "Mike R." wrote in message ... Greetings, This seems like such an easy question, but I have searched and just cannot find the answer. In my Workbook Open(), I would like to check the value of Q1 and if it = 1, then change the value to = 2. I have tried: If Range("Q39").Value = "1" Then Range("Q39").Value = "2" End If But it errors out... help... Mike |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy question - If ...then Change cell value
Hi
Buddy your code is fine but the cell reference in it is wrong. It should be "Q1" and not "Q39". If Range("Q1").Value = "1" Then Range("Q1").Value = "2" End If Thanks Karthik Bhat Bangalore |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy question - If ...then Change cell value
It should not be erring out, something else is up with that! Nor should it
matter whether you have quotes around the "1" and "2" as far as I can tell .... and the fact that you have mixed up Q1 and Q39 seems like an obvious typo that even if not what you meant, should not be generating an error, it should just behave in ways you were not desiring, Bill "Mike R." wrote in message ... Greetings, This seems like such an easy question, but I have searched and just cannot find the answer. In my Workbook Open(), I would like to check the value of Q1 and if it = 1, then change the value to = 2. I have tried: If Range("Q39").Value = "1" Then Range("Q39").Value = "2" End If But it errors out... help... Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy/Paste cell down to next value- Easy question, can't figure it | Excel Discussion (Misc queries) | |||
Easy VBA question | Excel Discussion (Misc queries) | |||
Easy Question | Excel Worksheet Functions | |||
new user with easy question? not easy for me | New Users to Excel | |||
easy question .... i think | Excel Discussion (Misc queries) |