Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get current cell value and place formula based on it in another column

Hi,

I'm trying to get a macro that will allow me to get information from a
separate worksheet based on the text in the currently select cell, and
place it 5 columns to the right. I got the vlookup working fine if not
in the macro, but when i execute it It says "Method 'FormulaR1C1' of
object 'range' failed".

Help is greatly appreciated. Thanks

Francisco Roque


Sub GetPriceandCount()
'
' GetPriceandCount Macro
' Macro recorded 09/10/2006 by Francisco Roque
'
' Keyboard Shortcut: Option+Cmd+p
'
Dim itemName As String
itemName = ActiveCell.Value
ActiveCell.Offset(0, 5).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(armourName;
Database!$A$1:$P$3869;13;FALSE)/100"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Get current cell value and place formula based on it in anothercolumn

Your code is using .Formula (not .formular1c1).

ActiveCell.Formula _
= "=VLOOKUP(armourName,Database!$A$1:$P$3869,13,FALS E)/100"

or if using .formular1c1

ActiveCell.FormulaR1C1 _
= "=VLOOKUP(armourName,Database!r1c1:r3869c16,13,FAL SE)/100"

R1C1 is A1
R3869C16 is P3869

But notice that I changed your list separator from semicolon to comma. VBA is
USA centric.

wrote:

Hi,

I'm trying to get a macro that will allow me to get information from a
separate worksheet based on the text in the currently select cell, and
place it 5 columns to the right. I got the vlookup working fine if not
in the macro, but when i execute it It says "Method 'FormulaR1C1' of
object 'range' failed".

Help is greatly appreciated. Thanks

Francisco Roque

Sub GetPriceandCount()
'
' GetPriceandCount Macro
' Macro recorded 09/10/2006 by Francisco Roque
'
' Keyboard Shortcut: Option+Cmd+p
'
Dim itemName As String
itemName = ActiveCell.Value
ActiveCell.Offset(0, 5).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(armourName;
Database!$A$1:$P$3869;13;FALSE)/100"


--

Dave Peterson
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
Static current date based on when data in another column was enter Daniel Excel Worksheet Functions 3 December 4th 09 05:13 PM
Run a macro in active cell only. Want to place current date/time. time clock watcher Excel Worksheet Functions 3 July 20th 09 07:46 AM
Place number into Cell Based on Match Walter Excel Discussion (Misc queries) 4 June 8th 07 06:24 PM
Can I get current #row or #column in cell formula? ryany Excel Discussion (Misc queries) 2 February 13th 06 11:27 AM
How to populate column with formula based on value in cell Cameron Stewart Excel Programming 2 November 2nd 04 01:36 AM


All times are GMT +1. The time now is 11:56 PM.

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

About Us

"It's about Microsoft Excel"