Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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
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
Excel 2007 single cell selecting muliple cell Submit2s Excel Worksheet Functions 1 February 12th 09 04:52 PM
Selecting a cell entry based on cell validation selection Brutalius Excel Worksheet Functions 2 December 17th 08 03:44 AM
Transfer cell values to another cell by selecting button. Gryndar Excel Worksheet Functions 2 November 24th 08 02:21 AM
Selecting A cell... LeahT Excel Discussion (Misc queries) 6 April 16th 08 06:48 PM
Selecting a certain cell Bernd[_2_] Excel Programming 5 November 25th 03 08:18 PM


All times are GMT +1. The time now is 05:11 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"