determining last column

  • Thread starter Thread starter jacqui
  • Start date Start date
J

jacqui

I am trying to setup a print range based on variables My
formula is

Range("A" & iRStrt, " " & iRFin)

I've coded the iRStrt and iRFin bit which works out the
start and end rows, however you will notice the " ", this
is because I'm stuck with this bit. I don't want to hard
code it, ie I know the actual end column is "Y" but this
might change.
Elsewhere in my code I use the following formula to
determine my last column

iCCount = ActiveSheet.Range("IV7").End(xlToLeft).Column

however this returns an integer value, how would I get the
equivalent but expressed as the column letter?

Does this make sense?
Am I going about this the right way?
Can anyone help?

Many thanks
Jacqui
 
You can use the Cells function. For example, to select
range B1:J10, you can use:

Range(Cells(1,2).Address & ":" & Cells
(10,10).Address).Select

Just change the hard coded integer values to variables to
suit your needs.
 
if icCount returns the last column -
then your print range formula is

Range(cells(iRStrt,icCount),cells(iRFin,icCount))

you did 98% of it yourself ... well done

Patrick Molloy
Microsoft Excel MVP
 
Heres a couple of ways of doing it:-

Range("C3").Select
ActiveWorkbook.Names.Add Name:="start", RefersToR1C1:=ActiveCell
Selection.End(xlToRight).Select
Selection.End(xlDown).Select
ActiveWorkbook.Names.Add Name:="finish", RefersToR1C1:=ActiveCell
Application.Goto Reference:="start:finish"


StartR = ActiveCell.Row
StartC = ActiveCell.Column
Selection.End(xlToRight).Select
Selection.End(xlDown).Select
FinishR = ActiveCell.Row
FinishC = ActiveCell.Column
Range(Cells(StartR, StartC), Cells(FinishR, FinishC)).Select


Dave
 
Back
Top