Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Referring to cells

I am writing a macro that with the use of some code creates charts of some
data avaliable on a spreadsheet. My problem is that the cells that are to be
used for the charts are different every time. I do not know how to refer to a
cell "variably". The problem is that I search the spreadsheet for certain
texts and when found I want them to be e.g. headlines in the chart.

Set rng = Worksheets("Indata").Cells.Find("Date", LookIn:=xlValues)

This cell e.g. how do you refer to it or cells in the same row/column etc.?
rng.Address gives you the adress. but howe.g. loop something with it? what i
want to know is is there any way to get the adress from a cell in a format
that you e.g. can add 1 to the rows or columns?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Referring to cells

Dim rng as Range
Dim rng1 as Range
Set rng = Worksheets("Indata").Cells.Find("Date", LookIn:=xlValues)

-----------------------
With Worksheets("Indata")
set rng1 = .Range(rng,rng1.End(xldown))
End With
msgbox rng.Address, rng1.Address
----------------------


rng.offset(1,0)
is the next cell below the header

rng.offset(0,1)
is the next cell the right of the header

negative numbers are up and left

--
Regards,
Tom Ogilvy


"april27" wrote:

I am writing a macro that with the use of some code creates charts of some
data avaliable on a spreadsheet. My problem is that the cells that are to be
used for the charts are different every time. I do not know how to refer to a
cell "variably". The problem is that I search the spreadsheet for certain
texts and when found I want them to be e.g. headlines in the chart.

Set rng = Worksheets("Indata").Cells.Find("Date", LookIn:=xlValues)

This cell e.g. how do you refer to it or cells in the same row/column etc.?
rng.Address gives you the adress. but howe.g. loop something with it? what i
want to know is is there any way to get the adress from a cell in a format
that you e.g. can add 1 to the rows or columns?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Referring to cells

Range.Offset(rowoffset, columnoffset).
I.e., Range("D6").Offset(-2,3) would be Range("G4"), 2 rows up, 3
columns to the right.
If the values you seek are in the 5 cells below your found cell, the
range to graph would be Range(rng.offset(1,0),rng.offset(6,0))


april27 wrote:
I am writing a macro that with the use of some code creates charts of some
data avaliable on a spreadsheet. My problem is that the cells that are to be
used for the charts are different every time. I do not know how to refer to a
cell "variably". The problem is that I search the spreadsheet for certain
texts and when found I want them to be e.g. headlines in the chart.

Set rng = Worksheets("Indata").Cells.Find("Date", LookIn:=xlValues)

This cell e.g. how do you refer to it or cells in the same row/column etc.?
rng.Address gives you the adress. but howe.g. loop something with it? what i
want to know is is there any way to get the adress from a cell in a format
that you e.g. can add 1 to the rows or columns?


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
Referring to cells on a different worksheet GARY Excel Discussion (Misc queries) 3 November 10th 09 12:24 AM
IF Formula referring to 2 cells Marilyn Excel Discussion (Misc queries) 1 March 22nd 09 08:45 PM
Referring to Cells PeterM Excel Discussion (Misc queries) 4 May 30th 08 02:37 PM
Sort a list with cells referring to others cells Friis(DK) Excel Discussion (Misc queries) 6 February 24th 07 03:56 AM
referring to other cells with formulas ALex Excel Worksheet Functions 1 April 11th 05 05:14 PM


All times are GMT +1. The time now is 09:37 PM.

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"