Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
selecting a cell
Hi, I want to change the background of a cell using macro. I am referencing the worksheet with variable ws1 and the cell parameters are i (row) and j (col). I am trying to select the corresponding cell with code ws1.cells(i,j).select but its showing error. Can you please tell me how can i select a cell. Regards, Ashish -- ashishprem ------------------------------------------------------------------------ ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485 View this thread: http://www.excelforum.com/showthread...hreadid=534080 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
selecting a cell
try ws1.select cells(i,j).selec -- Zur ----------------------------------------------------------------------- Zurn's Profile: http://www.excelforum.com/member.php...fo&userid=1464 View this thread: http://www.excelforum.com/showthread.php?threadid=53408 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
selecting a cell
I don't have problem with the statements...
Sub testing() Dim ws1 As Worksheet Dim i%, j% Set ws1 = Worksheets("Sheet1") i = 5 j = 7 ws1.Cells(i, j).Select End Sub Regards, Edwin Tam http://www.vonixx.com "ashishprem" wrote: Hi, I want to change the background of a cell using macro. I am referencing the worksheet with variable ws1 and the cell parameters are i (row) and j (col). I am trying to select the corresponding cell with code ws1.cells(i,j).select but its showing error. Can you please tell me how can i select a cell. Regards, Ashish -- ashishprem ------------------------------------------------------------------------ ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485 View this thread: http://www.excelforum.com/showthread...hreadid=534080 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
selecting a cell
What error are you getting?
You code works for me if ws1 is the active sheet and i and j are valid values. You can't select a cell on a non-active sheet. If your sheet is not active, you could use ws1.Select cells(i, j).Select or Application.Goto ws1.cells(i, j) but if you want to change the background color, you don't need to select at all: ws1.cells(i, j).Interior.ColorIndex = 3 will change the background color without ever selecting. In general, using the range object directly is faster, results in smaller code, and in my opinion, is easier to maintain. In article , ashishprem wrote: Hi, I want to change the background of a cell using macro. I am referencing the worksheet with variable ws1 and the cell parameters are i (row) and j (col). I am trying to select the corresponding cell with code ws1.cells(i,j).select but its showing error. Can you please tell me how can i select a cell. Regards, Ashish |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 single cell selecting muliple cell | Excel Worksheet Functions | |||
Selecting a cell entry based on cell validation selection | Excel Worksheet Functions | |||
Transfer cell values to another cell by selecting button. | Excel Worksheet Functions | |||
Selecting A cell... | Excel Discussion (Misc queries) | |||
Selecting a certain cell | Excel Programming |