#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Vlookup's in macros

Im trying to create a macro that has a vlookup in it. When I copy the
vlookup to the cell below itself (copy from b2 to b3), the vlookup still
references the previous cell (example a2,c2:h4,1,false, where the a2 does not
automatically change to a3 when copied to b3).
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,886
Default Vlookup's in macros

Hi

How did you do the copy?
If you highlit the formula in the formula bar, did Copy, Esc and then
Pasted to A3 the formula would not cage.
If you copied cell A2 and Pasted to cell A3 it will, or if you drag with
the fill handle.

You don't show any $ signs in your formula, so I am presuming that you
don't have absolute references set like
=VLOOKUP($A$2,C2:H4,1,false)

Also, as your offset is 1, it should be returning the same value as
exists in A2, provided that exists within the range C2:C4.
Is that what you wanted?

--
Regards

Roger Govier


"Desiree" wrote in message
...
Im trying to create a macro that has a vlookup in it. When I copy the
vlookup to the cell below itself (copy from b2 to b3), the vlookup
still
references the previous cell (example a2,c2:h4,1,false, where the a2
does not
automatically change to a3 when copied to b3).



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Vlookup's in macros

Roger,
I double clicked the handle at the bottom right of the cell to automatically
fill to the bottom of the entire data set. Is there a way that I can go into
visual basic to rewright the code to make it say "always reference one cell
to the left?" For example, instead of putting vlookup(a2,$c$2:$h$4,2,false),
could I put something along the lines of vlookup(1 cell to the
left,$c$2:$h$4,2,false)?

"Roger Govier" wrote:

Hi

How did you do the copy?
If you highlit the formula in the formula bar, did Copy, Esc and then
Pasted to A3 the formula would not cage.
If you copied cell A2 and Pasted to cell A3 it will, or if you drag with
the fill handle.

You don't show any $ signs in your formula, so I am presuming that you
don't have absolute references set like
=VLOOKUP($A$2,C2:H4,1,false)

Also, as your offset is 1, it should be returning the same value as
exists in A2, provided that exists within the range C2:C4.
Is that what you wanted?

--
Regards

Roger Govier


"Desiree" wrote in message
...
Im trying to create a macro that has a vlookup in it. When I copy the
vlookup to the cell below itself (copy from b2 to b3), the vlookup
still
references the previous cell (example a2,c2:h4,1,false, where the a2
does not
automatically change to a3 when copied to b3).




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,886
Default Vlookup's in macros

Hi

I think you need to explain with examples of what your data consists of,
what it is that you are trying to do.
It might be that you should be using something other than Vlookup.
It you can show some examples of what the data is in cells C2:H4 and
what is in A2 and what you want to achieve, then I'm sure we should be
able to help you.

--
Regards

Roger Govier


"Desiree" wrote in message
...
Roger,
I double clicked the handle at the bottom right of the cell to
automatically
fill to the bottom of the entire data set. Is there a way that I can
go into
visual basic to rewright the code to make it say "always reference one
cell
to the left?" For example, instead of putting
vlookup(a2,$c$2:$h$4,2,false),
could I put something along the lines of vlookup(1 cell to the
left,$c$2:$h$4,2,false)?

"Roger Govier" wrote:

Hi

How did you do the copy?
If you highlit the formula in the formula bar, did Copy, Esc and then
Pasted to A3 the formula would not cage.
If you copied cell A2 and Pasted to cell A3 it will, or if you drag
with
the fill handle.

You don't show any $ signs in your formula, so I am presuming that
you
don't have absolute references set like
=VLOOKUP($A$2,C2:H4,1,false)

Also, as your offset is 1, it should be returning the same value as
exists in A2, provided that exists within the range C2:C4.
Is that what you wanted?

--
Regards

Roger Govier


"Desiree" wrote in message
...
Im trying to create a macro that has a vlookup in it. When I copy
the
vlookup to the cell below itself (copy from b2 to b3), the vlookup
still
references the previous cell (example a2,c2:h4,1,false, where the
a2
does not
automatically change to a3 when copied to b3).






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
Can't Open Excel Files with Macros Charles A C Excel Discussion (Misc queries) 1 January 9th 07 03:52 AM
Macros Don't Show On Commands List and 'Normal.dot' SV Excel Worksheet Functions 3 December 13th 06 07:23 PM
Deleting phantom macros [email protected] Setting up and Configuration of Excel 2 September 8th 06 11:47 AM
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
how do I run excel 4.0 macros on excel 2000 RodolfoDallas Excel Discussion (Misc queries) 1 March 12th 06 03:14 AM


All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"