How to link command button macros

Bushman

New Member
Joined
May 23, 2010
Messages
24
Hello, I am in need of assistance with a spreadsheet I've been working on (with help from MREXCEL, ty). :)
Firstly I'm trying to link three macros which I had set up seperately but realise they can run together with one prompt, how do I do this? :confused:
Secondly I have been trying to get the DatedSaveData macro (that I tried my first record macro shortcut as I know very little VB) to paste a range of copied values into the first empty column on a sheet I have called "Saved" but so far I am chasing my tail, please help! :eek:

Code:
Sub ViewData_Click()
 'Unhide cells
    Sheet3.Columns("H:J").EntireColumn.Hidden = _
    Not Sheet3.Columns("H:J").EntireColumn.Hidden
End Sub
Private Sub CommandButton1_Click()
    ' Clear cells in a range
    Sheets("Sheet1").Range("J10:L56").ClearContents
End Sub

Sub DatedSaveData2()
    ' 
    Sheets("Saved").Select
    ' Insert Date at the top of the first empty column
    ActiveCell.FormulaR1C1 = "=NOW()"
    ' Copy data from sheet "All"
    Sheets("All").Select
    Range("K11:K39").Select
    Selection.Copy
    ' Paste to first empty cell below date on sheet "saved"
    Sheets("Saved").Select
    Range("A1").End(xlDown).Offset(1, 0).Select
    ActiveSheet.Paste
    'Copy data from sheet "Hoodies"
    Sheets("Hoodies").Select
    Range("K40:K56").Select
    Application.CutCopyMode = False
    Selection.Copy
    ' Paste to first empty cell below last paste
    Sheets("Saved").Select
    Range("A1").End(xlDown).Offset(1, 0).Select
    ActiveSheet.Paste
    ' Select sheet "Hoodies"
    Sheets("Hoodies").Select
End Sub
 
Looks perfect! How will you do that?

Apparently with lots more effort than I expected while posting above. I thought I had it cracked but yeah... complications...

Now then:
Code:
 Sub DatedSaveData2()

With Worksheets("Saved")

If .Range("A1") = "" Then
Set firstempty = .Range("A1")
Else
Set firstempty = .Range(.Cells(1, Columns.Count).Address).End(xlToLeft).Offset(0, 1) 'Address
End If

    firstempty.FormulaR1C1 = "=NOW()"

    Worksheets("All").Range("K11:K39").Copy Destination:= _
    firstempty.Offset(1, 0)


    Worksheets("Hoodies").Range("K40:K56").Copy Destination:= _
    firstempty.End(xlDown).Offset(1, 0)

End With
    Worksheets("Hoodies").Select
End Sub
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Snowblizz that's brilliant, thank you very much for that.

The code works great. I'm going to try and get it to work so that it deletes the ranges on sheets "All" and "Hoodies" tho.

Thanks again for all of you effort!!!
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,901
Members
449,194
Latest member
JayEggleton

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
Back
Top