can someone please tell me how to reference cell A1 in a macro?
reference cell in macro
- zotee98
- Closed
-
-
-
Re: reference cell in macro
range("A1")
to select:
range("A1").selectHTH
-
Re: reference cell in macro
what about if it is on a different sheet? - thanks for the last answer.
-
Re: reference cell in macro
sheets("Sheet2").range("A1").select 'different sheet
-
-
-
Re: reference cell in macro
I Am Now Running Into A Problem With The Cell Color. I Am Using Data Valadation And The Code I Am Using Only Works If You Hit The Enter Key. So When You Are Using Data Valadation With Drop Downs It Doesnt Work. Any Ideas?
Thanks In Advance.
-
Re: reference cell in macro
Just to summarize and add to the previous posts
Code
Display More'METHODS OF REFERENCING WORKSHEET CELLS FROM A MACRO 'Method 1 - referencing a range directly Sheets("Sheet1").Range("A1").Select 'Method 2 - referencing Cells using a row, column index notation Sheets("Sheet1").Cells(1, 1).Select '(1,1) = (row, column) 'Method 3 - refencing Cells using variables 'very useful if these will be changing in a loop 'say you have an operation you need to do on every row MyDataRow = 1 MyDataColumn = 1 Sheets("Sheet1").Cells(MyDataRow, MyDataColumn).Select '------------ ' To verify any of these, put this code just after the method ' With Selection.Interior ' .ColorIndex = 6 ' .Pattern = xlSolid ' End With
-
Re: reference cell in macro
Do You Have Any Thoughts On How To Color Code The Cell When Using Data Valadation?
-
Re: reference cell in macro
Quote from zotee98Do You Have Any Thoughts On How To Color Code The Cell When Using Data Valadation?
Try using Format --> Conditional Formatting within Excel (non Visual Basic method)
You can have the color of a cell change when its within values (conditions) that you specify. This is what you probably want in addition to the Data Validation function you are describing. -
Re: reference cell in macro
Mike
That Wont Work Because The Row Highlighter That I Am Using Uses Conditional Formating. Also I Need More Then Three Formats.
-
Re: reference cell in macro
Quote from zotee98Mike
That Wont Work Because The Row Highlighter That I Am Using Uses Conditional Formating. Also I Need More Then Three Formats.
Zotee,
Could you describe your problem more or post an example file as an attachment? Your question has grown a bit more than just referencing cell A1. It sounds like you might have to take a step back from using the Excel worksheet functions like Conditional Formatting and Data Validation and write a strictly Visual Basic way logic to do what needs to be done. I say this because you say you need more than three conditions to check against (exceeding the limit of Conditional Formatting). But where there is a will, there is a often a way to do something with the worksheet functions. Have you considered using Hidden columns of data on which to check extra conditions, using IF logic statements (you can nest up to seven conditions with the IF logic)? -
Re: reference cell in macro
zotee98, please start a New Thread with your other question. I'm locking this post, sorry macromike.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!