Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Applying vlookup to a range

Hi,
I have to apply vlookup formula to a range which is nto pre-defined.The
script must identify the last row in a column and than apply the formula
after the last used row and 500 cells below that.

What I have done is found then Last row using:
LastRow = objExcel.Cells.Find(What:="*", After:=objExcel.Range("A1"), _
searchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
I use the following formula for Vlookup for an identified range:
Range("$B2:B1000").Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

I replace the above formula as below:
Range("$B"&LastRow &:$1000).Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

This gives syntax error.
It would be rally nice if someone can tell me how can I pass this variable
to the Range.I tried various other options but it doesnot seem to work.


Thanks a lot.

Thanks and Regards,
shal



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Applying vlookup to a range

Range("$B"&LastRow &":$B1000").Formula = _

HTH
--
AP

"Shal" a écrit dans le message de
...
Hi,
I have to apply vlookup formula to a range which is nto pre-defined.The
script must identify the last row in a column and than apply the formula
after the last used row and 500 cells below that.

What I have done is found then Last row using:
LastRow = objExcel.Cells.Find(What:="*", After:=objExcel.Range("A1"), _
searchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
I use the following formula for Vlookup for an identified range:
Range("$B2:B1000").Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

I replace the above formula as below:
Range("$B"&LastRow &:$1000).Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

This gives syntax error.
It would be rally nice if someone can tell me how can I pass this variable
to the Range.I tried various other options but it doesnot seem to work.


Thanks a lot.

Thanks and Regards,
shal





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Applying vlookup to a range

Thanks a lot for the syntax correction.One more thing.
When I apply to use the same syntax for Vlookup it gives a syntax error.

Range("$B" & LastRow + 1 & ":$B1000").Formula = _
"=VLOOKUP("$A" & (LastRow +1) & ,'SAP DATA'!$A$12:$B$1000,2,FALSE)"
It says invalid character for $A

Thanks for the help.

Thanks and Regards,
Shalini Nahata


"Ardus Petus" wrote:

Range("$B"&LastRow &":$B1000").Formula = _

HTH
--
AP

"Shal" a écrit dans le message de
...
Hi,
I have to apply vlookup formula to a range which is nto pre-defined.The
script must identify the last row in a column and than apply the formula
after the last used row and 500 cells below that.

What I have done is found then Last row using:
LastRow = objExcel.Cells.Find(What:="*", After:=objExcel.Range("A1"), _
searchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
I use the following formula for Vlookup for an identified range:
Range("$B2:B1000").Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

I replace the above formula as below:
Range("$B"&LastRow &:$1000).Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

This gives syntax error.
It would be rally nice if someone can tell me how can I pass this variable
to the Range.I tried various other options but it doesnot seem to work.


Thanks a lot.

Thanks and Regards,
shal






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Applying vlookup to a range

Range("$B" & LastRow + 1 & ":$B1000").Formula = _
"=VLOOKUP($A" & Lastrow &" ,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

HTH
--
AP

"Shal" a écrit dans le message de
...
Thanks a lot for the syntax correction.One more thing.
When I apply to use the same syntax for Vlookup it gives a syntax error.

Range("$B" & LastRow + 1 & ":$B1000").Formula = _
"=VLOOKUP("$A" & (LastRow +1) & ,'SAP

DATA'!$A$12:$B$1000,2,FALSE)"
It says invalid character for $A

Thanks for the help.

Thanks and Regards,
Shalini Nahata


"Ardus Petus" wrote:

Range("$B"&LastRow &":$B1000").Formula = _

HTH
--
AP

"Shal" a écrit dans le message de
...
Hi,
I have to apply vlookup formula to a range which is nto

pre-defined.The
script must identify the last row in a column and than apply the

formula
after the last used row and 500 cells below that.

What I have done is found then Last row using:
LastRow = objExcel.Cells.Find(What:="*", After:=objExcel.Range("A1"),

_
searchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
I use the following formula for Vlookup for an identified range:
Range("$B2:B1000").Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

I replace the above formula as below:
Range("$B"&LastRow &:$1000).Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

This gives syntax error.
It would be rally nice if someone can tell me how can I pass this

variable
to the Range.I tried various other options but it doesnot seem to

work.


Thanks a lot.

Thanks and Regards,
shal








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Applying vlookup to a range


Thanks Ardus. It was really helpful.
Regards,
Shals


"Ardus Petus" wrote:

Range("$B" & LastRow + 1 & ":$B1000").Formula = _
"=VLOOKUP($A" & Lastrow &" ,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

HTH
--
AP

"Shal" a écrit dans le message de
...
Thanks a lot for the syntax correction.One more thing.
When I apply to use the same syntax for Vlookup it gives a syntax error.

Range("$B" & LastRow + 1 & ":$B1000").Formula = _
"=VLOOKUP("$A" & (LastRow +1) & ,'SAP

DATA'!$A$12:$B$1000,2,FALSE)"
It says invalid character for $A

Thanks for the help.

Thanks and Regards,
Shalini Nahata


"Ardus Petus" wrote:

Range("$B"&LastRow &":$B1000").Formula = _

HTH
--
AP

"Shal" a écrit dans le message de
...
Hi,
I have to apply vlookup formula to a range which is nto

pre-defined.The
script must identify the last row in a column and than apply the

formula
after the last used row and 500 cells below that.

What I have done is found then Last row using:
LastRow = objExcel.Cells.Find(What:="*", After:=objExcel.Range("A1"),

_
searchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
I use the following formula for Vlookup for an identified range:
Range("$B2:B1000").Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

I replace the above formula as below:
Range("$B"&LastRow &:$1000).Formula = _
"=VLOOKUP($A2,'SAP DATA'!$A$12:$B$1000,2,FALSE)"

This gives syntax error.
It would be rally nice if someone can tell me how can I pass this

variable
to the Range.I tried various other options but it doesnot seem to

work.


Thanks a lot.

Thanks and Regards,
shal









thanks



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
Applying Formulas to a Range in a Worksheet Ra Excel Discussion (Misc queries) 4 June 15th 09 11:19 AM
Applying Conditional Formatting to a Max number in range SunshineinFt.Myers Excel Worksheet Functions 5 February 24th 09 02:43 AM
Applying Offset to Range in VBA [email protected] Excel Worksheet Functions 2 June 21st 06 04:01 AM
Applying data range to column width Splash Charts and Charting in Excel 2 November 25th 05 02:53 PM
Applying formula to only NON-EMPTY cells in range Tasi Excel Discussion (Misc queries) 5 March 29th 05 10:48 PM


All times are GMT +1. The time now is 05:44 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"