ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set name fails (https://www.excelbanter.com/excel-programming/389140-set-name-fails.html)

Oldjay

Set name fails
 
When I try to run this code it fails to accept the "NameSave" It says <Method
"Range" of object'_Globle"failed

Private Sub CommandButton4_Click() 'Saves wookbook and exits


Dim NameSave As Range
Dim DateSave As Range

Sheets("Summary").Select

Set NameSave = Range("Summary!A2")
Set DateSave = Range("Summary!E213")

etc.

oldjasy

[email protected]

Set name fails
 
Hi
In VBA code you use
Set NameSave = Worksheets("Summary").Range("A2")
etc

yours is like worksheet function syntax.
regards
Paul

On May 10, 4:31 pm, Oldjay wrote:
When I try to run this code it fails to accept the "NameSave" It says <Method
"Range" of object'_Globle"failed

Private Sub CommandButton4_Click() 'Saves wookbook and exits

Dim NameSave As Range
Dim DateSave As Range

Sheets("Summary").Select

Set NameSave = Range("Summary!A2")
Set DateSave = Range("Summary!E213")

etc.

oldjasy




Oldjay

Set name fails
 
Thanks
One more question I wish to save this file using the date in DateSave.
The reference cell J213 is formated as 01-May-07 but DateSave formats as
5/1/07 which does save correctly because of th /'s\

Is there any way to change DateSave to the format in J213?

BankRecords = InputBox("Please enter file name to save", "Bank Records
Backup", "C:\Bank Records\" & NameSave & "" & DateSave)





" wrote:

Hi
In VBA code you use
Set NameSave = Worksheets("Summary").Range("A2")
etc

yours is like worksheet function syntax.
regards
Paul

On May 10, 4:31 pm, Oldjay wrote:
When I try to run this code it fails to accept the "NameSave" It says <Method
"Range" of object'_Globle"failed

Private Sub CommandButton4_Click() 'Saves wookbook and exits

Dim NameSave As Range
Dim DateSave As Range

Sheets("Summary").Select

Set NameSave = Range("Summary!A2")
Set DateSave = Range("Summary!E213")

etc.

oldjasy





[email protected]

Set name fails
 
Hi
Try
DateSave = Format(DateValue(Range("J213").Text), "dd-mmm-yy")

regards
Paul

On May 10, 6:02 pm, Oldjay wrote:
Thanks
One more question I wish to save this file using the date in DateSave.
The reference cell J213 is formated as 01-May-07 but DateSave formats as
5/1/07 which does save correctly because of th /'s\

Is there any way to change DateSave to the format in J213?

BankRecords = InputBox("Please enter file name to save", "Bank Records
Backup", "C:\Bank Records\" & NameSave & "" & DateSave)





All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com