Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Paste and Paste Special No Longer Working - Excel 2003 | Excel Discussion (Misc queries) | |||
can you change the default paste method? (paste values) | Excel Discussion (Misc queries) | |||
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. | Excel Worksheet Functions | |||
Excel cut/Paste Problem: Year changes after data is copy and paste | Excel Discussion (Misc queries) |