Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default 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   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy/Paste cell down to next value- Easy question, can't figure it J. Catz. Excel Discussion (Misc queries) 2 November 4th 09 10:45 AM
Easy VBA question Dallman Ross Excel Discussion (Misc queries) 2 August 6th 07 01:26 AM
Easy Question Bob[_8_] Excel Worksheet Functions 9 July 14th 07 03:50 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
easy question .... i think Dean Excel Discussion (Misc queries) 1 January 6th 05 06:31 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"