View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default VBA get range from cell offset

On May 17, 4:30*pm, stainless wrote:
Sub InsertPicture(PictureFileName As String, _
TargetCell As Range, _
* * CenterH As Boolean, CenterV As Boolean)

However, my main code is using cell offsets in all
of the processing and I am unsure as to how to convert
my offset cell to the TargetCell value required above i.e.

Set fdcCell = FDCs.Cells(fdcrownumber, 1) -- the initial
cell definition

The cell I need to find the range value for is
fdcCell.Offset(0, 18)


I'm a bit confused. Why can't you simply pass fdcCell.Offset(0,18)
directly as the 2nd parameter to InsertPicture?

fdcCell.Offset(0,18) returns a Range of a single cell, given how you
set fdcCell in the first place. Look at fdcCell.Offset(0,18).Address.

Are you looking for a multicell range? Is so, what defines the limits
of the range? Look at something like
Range(fdcCell.Offset(0,18),fcdCell.Offset(5,22)).A ddress.

(Just making things up to demonstrate concepts.)

Note: Although I use .Address to display the ranges, you would pass
the object without .Address to the TargetCell parameter.