C
Chris Beall
Excel 2000.
After creating a new worksheet with a macro, I want to save the contents
as an HTML page. I'm new to VB, so I've been using the macro recorder,
then tweaking the output.
Here's the problem. I'm trying to save just a range of cells, from A1
to the xlCellTypeLastCell, containing data pasted in by the macro. If I
just record what I'm doing manually, ActiveWorkbook.PublishObjects.Add
uses an absolute range, like $A$1:$J$1253. The $A$1 is OK, but the
second value will vary from time to time as the dimension of the pasted
data changes.
So I tried jamming in $A$1:xlCellTypeLastCell, which caused VB to barf.
But I knew I could use a named (single-cell) range, so I did a GoTo
Special -> Last cell and added a range name to that cell, then used that
as the starting point for a range selection. The macro recorded this as:
Selection.SpecialCells(xlCellTypeLastCell).Select
ActiveWorkbook.Names.Add Name:="Last_cell", RefersToR1C1:= _
"=Inventory!R61C10"
But R61C10 is an absolute reference, so that's no good.
What I seem to need is a way to refer to the currently-selected cell
when setting the range name, something like:
ActiveWorkbook.Names.Add Name:="Last_cell", RefersToR1C1:= _
"=Selected"
Does such a thing exist?
Chris Beall
After creating a new worksheet with a macro, I want to save the contents
as an HTML page. I'm new to VB, so I've been using the macro recorder,
then tweaking the output.
Here's the problem. I'm trying to save just a range of cells, from A1
to the xlCellTypeLastCell, containing data pasted in by the macro. If I
just record what I'm doing manually, ActiveWorkbook.PublishObjects.Add
uses an absolute range, like $A$1:$J$1253. The $A$1 is OK, but the
second value will vary from time to time as the dimension of the pasted
data changes.
So I tried jamming in $A$1:xlCellTypeLastCell, which caused VB to barf.
But I knew I could use a named (single-cell) range, so I did a GoTo
Special -> Last cell and added a range name to that cell, then used that
as the starting point for a range selection. The macro recorded this as:
Selection.SpecialCells(xlCellTypeLastCell).Select
ActiveWorkbook.Names.Add Name:="Last_cell", RefersToR1C1:= _
"=Inventory!R61C10"
But R61C10 is an absolute reference, so that's no good.
What I seem to need is a way to refer to the currently-selected cell
when setting the range name, something like:
ActiveWorkbook.Names.Add Name:="Last_cell", RefersToR1C1:= _
"=Selected"
Does such a thing exist?
Chris Beall