Can an object be named with the time or date + time

teamsimpson

New Member
Joined
Sep 20, 2002
Messages
22
Does anyone know any code (or if it can be done) that will let me use the .Name = "get time off clock" to name the object.That way if my code is run several times, the objects are named as a time, so each name will be different so i won't have to write code that has to check the name before it renames the object.
Regards
Mike
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Even if this were possible I am not sure that it would serve your purpose. What is your code doing? Post a snippet.
 

teamsimpson

New Member
Joined
Sep 20, 2002
Messages
22
Sub Macro2()

' Keyboard Shortcut: Ctrl+q


Sheets("TEST").OLEObjects.Add(FileName:="h:data.xls", Link:=False).Name = "new"

With Sheets("TEST").OLEObjects("new")
.Left = 200
.Top = 200
.Width = 40
.Height = 25

ActiveSheet.Shapes("new").Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 40
ActiveSheet.Shapes("new").Name = "data 1"

End With
Sheets("TEST").[a1].Activate
End Sub
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
The best way to keep track of your shape is to assign it to an Object variable when you add it. Like this:

Code:
Sub Test()
    Dim MyShape As OLEObject
    Set MyShape = Sheets("TEST").OLEObjects.Add(Filename:="h:data.xls", Link:=False)
    With MyShape
        .Left = 200
        .Top = 200
        .Width = 40
        .Height = 25
        .ShapeRange.Fill.ForeColor.SchemeColor = 40
        .Name = "data 1"
    End With
    Sheets("TEST").[a1].Activate
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,809
Messages
5,598,202
Members
414,218
Latest member
speedbit

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top