PC Review


Reply
Thread Tools Rate Thread

Changing absolute address to a relative address

 
 
Highlystrung
Guest
Posts: n/a
 
      24th Oct 2008
I'm trying to programme the creation of a vlookup table and created this
code with the macro recorder:

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Sheet4!R1C1:R84C4,4,FALSE)"

As the table I'm referencing (Sheet4) may expand I'm trying to pick up the
table range in a variable using:

strTableRange = Range.CurrentRegion.Select.

However this gives me an absolute address e.g. "A184". I need to convert
this into an absolute address to go into the vlookup. Can you advise of best
way to do this? many thanks,
--
thanks, Neil
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      24th Oct 2008
I'd let excel do the work:

Dim strTableRange As String
strTableRange = Worksheets("sheet4").Range("A1") _
.CurrentRegion.Address(external:=True, _
ReferenceStyle:=xlR1C1)

activecell.formular1c1 = "=vlookup(rc[-1]," & strtablerange & ",4,false)"

Highlystrung wrote:
>
> I'm trying to programme the creation of a vlookup table and created this
> code with the macro recorder:
>
> ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Sheet4!R1C1:R84C4,4,FALSE)"
>
> As the table I'm referencing (Sheet4) may expand I'm trying to pick up the
> table range in a variable using:
>
> strTableRange = Range.CurrentRegion.Select.
>
> However this gives me an absolute address e.g. "A184". I need to convert
> this into an absolute address to go into the vlookup. Can you advise of best
> way to do this? many thanks,
> --
> thanks, Neil


--

Dave Peterson
 
Reply With Quote
 
Highlystrung
Guest
Posts: n/a
 
      24th Oct 2008
Dave, thanks for the advice, I'll try it out in the morning,
--
thanks, Neil


"Dave Peterson" wrote:

> I'd let excel do the work:
>
> Dim strTableRange As String
> strTableRange = Worksheets("sheet4").Range("A1") _
> .CurrentRegion.Address(external:=True, _
> ReferenceStyle:=xlR1C1)
>
> activecell.formular1c1 = "=vlookup(rc[-1]," & strtablerange & ",4,false)"
>
> Highlystrung wrote:
> >
> > I'm trying to programme the creation of a vlookup table and created this
> > code with the macro recorder:
> >
> > ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Sheet4!R1C1:R84C4,4,FALSE)"
> >
> > As the table I'm referencing (Sheet4) may expand I'm trying to pick up the
> > table range in a variable using:
> >
> > strTableRange = Range.CurrentRegion.Select.
> >
> > However this gives me an absolute address e.g. "A184". I need to convert
> > this into an absolute address to go into the vlookup. Can you advise of best
> > way to do this? many thanks,
> > --
> > thanks, Neil

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Relative to absolute address =?Utf-8?B?WW9ya2U=?= Microsoft Excel Misc 6 25th Oct 2007 07:47 PM
How do I avoid excel change absolute address to relative address =?Utf-8?B?TWlndWVs?= Microsoft Excel Misc 3 10th May 2007 11:18 PM
what is difference between absolute address and relative address? =?Utf-8?B?d2hhdCBpcyBkaWZmZXJlbmNlIGJldHdlZW4gYWJz Microsoft Excel Misc 1 22nd Jul 2006 08:17 AM
Excel and C# absolute and relative address's Krish Microsoft C# .NET 1 20th Jun 2004 11:17 AM
transform relative address to absolute address Franz Microsoft Dot NET Framework 1 1st Jun 2004 10:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:04 PM.