Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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
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
Macro to save data in one cell and add new data in cell below etc KLEM Excel Programming 2 December 27th 06 10:55 PM
macro to copy & paste cell data into another cell dannyboy Excel Programming 2 December 23rd 05 05:01 PM
Writing a macro to copy first cell down until next cell has data Gerald[_2_] Excel Programming 1 August 10th 05 10:06 PM
enter data in cell which will start macro to move data to sheet2 Tommy Excel Discussion (Misc queries) 0 May 12th 05 05:00 PM
I need a macro that copies that data from one cell on one sheet to a cell on another? cakonopka[_7_] Excel Programming 8 February 4th 04 01:34 PM


All times are GMT +1. The time now is 11:52 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"