Outputing Sheet names and dates

Mathias

New Member
Joined
Dec 1, 2004
Messages
10
Hi guys,

Need some help updating some code (below)
So here is some code that I did ages ago and now I've forgotten it all. Whether its good or crap, what this macro does is...

Based on a push of a button, it selects/copies the specific cell in "Sports", pastes it as a link in "Updates" with the hyperlink target to the same cell in selected in "Sports". This is used in a very large database where the "Updates" sheet is a quick reference summary.

I need help updating what gets outputed. As well as it pasting the copied cell it also needs to include the name of the sheet its from and the date when the button was clicked. for example in a list of sports in the "Sports" sheet, coping the cell with "Football" in it. I need the output in the "updates" sheet to read:

Football - Sports - 01/01/05 (as in the date pressed).

Currently it just outputs "Football".


Sub test_Click()

Range("sport1").Select
Selection.Copy
Sheets("Updates").Select

For x = 1 To 100

If Range("B4:B104").Rows(x).Text = "" Then

Range("B4:B104").Rows(x).Select
x = 100

End If

Next x

ActiveSheet.Paste
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"Sports!sport1"
Sheets("Sports").Select


End Sub

Thanks Chaps
Mathias
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

chiello

Well-known Member
Joined
Jan 18, 2005
Messages
848
In the following you can find a possible solution. A feedback about correct/uncorrect functioning is desirable.

Ciao :) :)

Sub test_Click()
Dim HypLinkNum As Long
Dim DestRange As Range
Dim MyString As String

'Hyperlink Text
MyString = ActiveSheet.Range("sport1") & " - " & ActiveSheet.Name & " - " & CStr(Date)
'Hyperlink Number acquisition
HypLinkNum = Sheets("Updates").Range("B4:B104").Hyperlinks.Count
'Destination range setting
Set DestRange = Sheets("Updates").Cells(4 + HypLinkNum, 2)

'If you need to maintain the format, uncomment the following statement
'ActiveSheet.Range("sport1").Copy Destination:=DestRange

ActiveSheet.Hyperlinks.Add Anchor:=DestRange, Address:="", SubAddress:= _
ActiveSheet.Name & "!sport1", TextToDisplay:=MyString

End Sub
 

Forum statistics

Threads
1,148,218
Messages
5,745,444
Members
423,952
Latest member
EduardoM

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