Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Using Cell Data for .Log name
Im currently using the code below:
Dim StartTime#, CurrentTime# Const TrialPeriod# = 90 Const ObscurePath$ = "C:\Program Files\Microsoft Office\" Const ObscureFile$ = "051506.Log" I would like the have the logname come from a cell in the workbook. I tried the following: Const ObscureFile$ = Worksheets("SheetA").cell("A8").Value Const ObscureFile$ = Worksheets("SheetA").[A8].range They both gave me compile errors. Any suggestions? Also, can the target cell be a formula and the resulting logname be that cell's displayed text? ( Ie: Cell A6 = 051506 , Cell A8 =A6&".Log" ) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Using Cell Data for .Log name
A constant has to have a constant value, not be a cell reference.
Try declaring it as a variable: Dim ObscureFile$ ObscureFile$ = Worksheets("SheetA").Range("A8").Text instead. You also can't make up syntax - Worksheets don't have a .cell property (they *do* have a .Cells property, which takes row and column number arguments). The above could also be written Dim ObscureFile$ ObscureFile$ = Worksheets("SheetA").Cells(8, 1).Text In article , Bob wrote: Im currently using the code below: Dim StartTime#, CurrentTime# Const TrialPeriod# = 90 Const ObscurePath$ = "C:\Program Files\Microsoft Office\" Const ObscureFile$ = "051506.Log" I would like the have the logname come from a cell in the workbook. I tried the following: Const ObscureFile$ = Worksheets("SheetA").cell("A8").Value Const ObscureFile$ = Worksheets("SheetA").[A8].range They both gave me compile errors. Any suggestions? Also, can the target cell be a formula and the resulting logname be that cell's displayed text? ( Ie: Cell A6 = 051506 , Cell A8 =A6&".Log" ) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Using Cell Data for .Log name
From Excel help:
Initialize constants with literals, previously declared constants, or literals and constants joined by operators (except the Is logical operator). So, I don't believe you'll be able to do what you are asking. However, you could Dim it ias a variable string and then set it to the value of A8 on Workbook_Open. Public ObscureFile As String Sub foofer() ObscureFile = Worksheets("SheetA").Range("A8").Text MsgBox ObscureFile End Sub Bob wrote: Im currently using the code below: Dim StartTime#, CurrentTime# Const TrialPeriod# = 90 Const ObscurePath$ = "C:\Program Files\Microsoft Office\" Const ObscureFile$ = "051506.Log" I would like the have the logname come from a cell in the workbook. I tried the following: Const ObscureFile$ = Worksheets("SheetA").cell("A8").Value Const ObscureFile$ = Worksheets("SheetA").[A8].range They both gave me compile errors. Any suggestions? Also, can the target cell be a formula and the resulting logname be that cell's displayed text? ( Ie: Cell A6 = 051506 , Cell A8 =A6&".Log" ) |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Using Cell Data for .Log name
ACK! JE beat me to it. :-)
JW wrote: From Excel help: Initialize constants with literals, previously declared constants, or literals and constants joined by operators (except the Is logical operator). So, I don't believe you'll be able to do what you are asking. However, you could Dim it ias a variable string and then set it to the value of A8 on Workbook_Open. Public ObscureFile As String Sub foofer() ObscureFile = Worksheets("SheetA").Range("A8").Text MsgBox ObscureFile End Sub Bob wrote: Im currently using the code below: Dim StartTime#, CurrentTime# Const TrialPeriod# = 90 Const ObscurePath$ = "C:\Program Files\Microsoft Office\" Const ObscureFile$ = "051506.Log" I would like the have the logname come from a cell in the workbook. I tried the following: Const ObscureFile$ = Worksheets("SheetA").cell("A8").Value Const ObscureFile$ = Worksheets("SheetA").[A8].range They both gave me compile errors. Any suggestions? Also, can the target cell be a formula and the resulting logname be that cell's displayed text? ( Ie: Cell A6 = 051506 , Cell A8 =A6&".Log" ) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to save data in one cell and add new data in cell below etc | Excel Programming | |||
macro to copy & paste cell data into another cell | Excel Programming | |||
Writing a macro to copy first cell down until next cell has data | Excel Programming | |||
enter data in cell which will start macro to move data to sheet2 | Excel Discussion (Misc queries) | |||
I need a macro that copies that data from one cell on one sheet to a cell on another? | Excel Programming |