Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using variables while running macro


Good day folks,

I have this code:

termmon = Month(Sheets("Main").Cells(9, 3)) + 1
Range("J30").Select
ActiveCell.FormulaR1C1 = "=HLOOKUP(""5 Days"",R[0]C[-8]:R[18]C[-2],
termmon, FALSE)"

When I try to use the variable "termmon" in the hlookup formula, I get
the #Name? in the active cell. I tried to copy and pastevalues in the
active cell but still the same thing happen. Do anyone know if there
is a way to get this to work?

Thank you

Chris


--
TheLeafs
------------------------------------------------------------------------
TheLeafs's Profile: http://www.excelforum.com/member.php...o&userid=10131
View this thread: http://www.excelforum.com/showthread...hreadid=517293

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Using variables while running macro

Try

ActiveCell.FormulaR1C1 = "=HLOOKUP(""5
Days"",R[0]C[-8]:R[18]C[-2]," & _
termmon & ", FALSE)"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"TheLeafs"
wrote in
message
...

Good day folks,

I have this code:

termmon = Month(Sheets("Main").Cells(9, 3)) + 1
Range("J30").Select
ActiveCell.FormulaR1C1 = "=HLOOKUP(""5
Days"",R[0]C[-8]:R[18]C[-2],
termmon, FALSE)"

When I try to use the variable "termmon" in the hlookup
formula, I get
the #Name? in the active cell. I tried to copy and pastevalues
in the
active cell but still the same thing happen. Do anyone know if
there
is a way to get this to work?

Thank you

Chris


--
TheLeafs
------------------------------------------------------------------------
TheLeafs's Profile:
http://www.excelforum.com/member.php...o&userid=10131
View this thread:
http://www.excelforum.com/showthread...hreadid=517293



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using variables while running macro


Thanks Chip

--
TheLeaf
-----------------------------------------------------------------------
TheLeafs's Profile: http://www.excelforum.com/member.php...fo&userid=1013
View this thread: http://www.excelforum.com/showthread.php?threadid=51729

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
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
macro calling another macro + variables yo Excel Discussion (Misc queries) 2 April 5th 06 04:36 PM
Passing variables from Outlook Macro to Excel Macro [email protected] Excel Programming 2 January 7th 05 10:07 PM
passing variables from an excel macro to a powerpoint macro jake Excel Programming 1 December 11th 03 02:36 AM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


All times are GMT +1. The time now is 02:22 AM.

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"