![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 01:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com