#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paste Down

Hi,

I am trying to paste my VLOOKUP formula down & am getting the following
error:

Run time error 438 - Object dosent support this property or method.

The VLookup works in the first cell (B2) but is not copied down to to
the rest of the cells in column B.

This is my code......

Worksheets("Group 40").Activate

Set CurrentCell = Range("A2")
Do While Not IsEmpty(CurrentCell)
Set CurrentCell = CurrentCell.Offset(0, 1)
Set NextCell = CurrentCell.Offset(1, 0)

Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1], '[Reportable
Accounts.xls]Sheet1'!R1C1:R1147C2,1,FALSE)"
CurrentCell.Copy
Selection.Paste
Application.CutCopyMode = False
Set CurrentCell = NextCell

Loop


I would like to copy the VLOOKUP Formula to the rest of the cells in
column B does anyone have any suggestions?

Thanks



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Paste Down

I don't use r1c1 but
Sub copyformula()
For Each c In Selection
c.Formula = "=vlookup(a1,$b$1:$c$5,2,false)"
c.Formula = c.Value 'will leave values only
Next
End Sub


"STEVEB" wrote in message
...
Hi,

I am trying to paste my VLOOKUP formula down & am getting the following
error:

Run time error 438 - Object dosent support this property or method.

The VLookup works in the first cell (B2) but is not copied down to to
the rest of the cells in column B.

This is my code......

Worksheets("Group 40").Activate

Set CurrentCell = Range("A2")
Do While Not IsEmpty(CurrentCell)
Set CurrentCell = CurrentCell.Offset(0, 1)
Set NextCell = CurrentCell.Offset(1, 0)

Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1], '[Reportable
Accounts.xls]Sheet1'!R1C1:R1147C2,1,FALSE)"
CurrentCell.Copy
Selection.Paste
Application.CutCopyMode = False
Set CurrentCell = NextCell

Loop


I would like to copy the VLOOKUP Formula to the rest of the cells in
column B does anyone have any suggestions?

Thanks



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Paste Down

Steve,

Since you never select a new cell after B2, "Selection.Paste" will always
paste into B2.

If you want to put the formula into every cell in column B, this seems to
work. However I notice that the formula seems to be returning the value
that is being looked up, so I'm not sure what it does. It certainly takes a
while to recalculate all those lookups (at least on my old PII).

Sub test()
Worksheets("Group 40").Columns(2).FormulaR1C1 = _
"=VLOOKUP(RC[-1], '[Reportable Accounts.xls]Sheet1'!R1C1:R1147C2,1,FALSE)"
End Sub

hth,

Doug

"STEVEB" wrote in message
...
Hi,

I am trying to paste my VLOOKUP formula down & am getting the following
error:

Run time error 438 - Object dosent support this property or method.

The VLookup works in the first cell (B2) but is not copied down to to
the rest of the cells in column B.

This is my code......

Worksheets("Group 40").Activate

Set CurrentCell = Range("A2")
Do While Not IsEmpty(CurrentCell)
Set CurrentCell = CurrentCell.Offset(0, 1)
Set NextCell = CurrentCell.Offset(1, 0)

Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1], '[Reportable
Accounts.xls]Sheet1'!R1C1:R1147C2,1,FALSE)"
CurrentCell.Copy
Selection.Paste
Application.CutCopyMode = False
Set CurrentCell = NextCell

Loop


I would like to copy the VLOOKUP Formula to the rest of the cells in
column B does anyone have any suggestions?

Thanks



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Paste Down

See my answer to your original question - the code I provided will be many
times faster than your inefficient loop. And it works.


Sub tester3()
Dim rng As Range
With Worksheets("Sheet 1") ' <= Want a space in the name?
Set rng = .Range(.Cells(2, 1), .Cells(Rows.Count, 1).End(xlUp))
End With
rng.Offset(0, 1).Formula = _
"=VLOOKUP(A2," & _
"'[FileName.xls]Sheet1'!" & _
"$A$2:$B$1147,2,FALSE)"

rng.Offset(0, 1).Formula = rng.Offset(0, 1).Value
End Sub


Might want the 3rd argument of Vlookup to be a 2 rather than a 1.


--
Regards,
Tom Ogilvy


STEVEB wrote in message
...
Hi,

I am trying to paste my VLOOKUP formula down & am getting the following
error:

Run time error 438 - Object dosent support this property or method.

The VLookup works in the first cell (B2) but is not copied down to to
the rest of the cells in column B.

This is my code......

Worksheets("Group 40").Activate

Set CurrentCell = Range("A2")
Do While Not IsEmpty(CurrentCell)
Set CurrentCell = CurrentCell.Offset(0, 1)
Set NextCell = CurrentCell.Offset(1, 0)

Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1], '[Reportable
Accounts.xls]Sheet1'!R1C1:R1147C2,1,FALSE)"
CurrentCell.Copy
Selection.Paste
Application.CutCopyMode = False
Set CurrentCell = NextCell

Loop


I would like to copy the VLOOKUP Formula to the rest of the cells in
column B does anyone have any suggestions?

Thanks



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paste Down

Hi Tom,

This formula worked great? Is there a way to autmatically delete all
"#N/A" cells that are returned as a result of the VLOOKUP?

Thanks for your help!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
Paste and Paste Special No Longer Working - Excel 2003 SheriJ Excel Discussion (Misc queries) 2 January 15th 09 09:23 PM
can you change the default paste method? (paste values) David A Brown Excel Discussion (Misc queries) 3 December 18th 07 09:59 AM
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. stan-the-man Excel Worksheet Functions 7 June 14th 06 08:10 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM


All times are GMT +1. The time now is 09:21 AM.

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"