Coping command button

hoyos

Board Regular
Joined
Jul 10, 2012
Messages
98
Office Version
  1. 365
Platform
  1. Windows
I have copied a command button and paste it in another sheet. I have managed to change the name but the macro won’t work. When right clicking the button I don’t get properties in the drop down box. Is there another way of accessing properties for the command button?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Is it a Form Control Button, or an ActiveX one?
 
Upvote 0
Then that's why you don't get a properties option in the context menu. What is it that you are trying to do?
 
Upvote 0
I have three buttons in total on a spreadsheet. Pressing button2 to loads the next period, pressing button3 loads the previous period and button1 shows the current period as a number from 0 to 13. But when button1 is copied and pasted on another sheet it’s not indicating what period you are at.
 
Upvote 0
What is the code behind button1?
 
Upvote 0
What is the code behind button1?
the following code:

VBA Code:
Sub PeriodBefore()
    P = Range("AB18")
    If P = 13 Then Exit Sub
    Range("D6:F33").Copy
    Cells(432 - (28 * P), 4).PasteSpecial (xlValues)
    Range("I6:K33").Copy
    Cells(432 - (28 * P), 9).PasteSpecial (xlValues)
    Range("O6:O33").Copy
    Cells(432 - (28 * P), 15).PasteSpecial (xlValues)
    Range("V6:Y33").Copy
    Cells(432 - (28 * P), 22).PasteSpecial (xlValues)
    Range("AB18") = P + 1: P = P + 1
    ActiveSheet.DrawingObjects("Button 2").Caption = "<--  Previous Period"
    ActiveSheet.DrawingObjects("Button 3").Caption = "Next 28 Day Period  -->  "
    ActiveSheet.DrawingObjects("Button 1").Caption = "Current Period = " & -P
    If P = 13 Then ActiveSheet.DrawingObjects("Button 1").Caption = "<--  First Period"
    Range(Cells(432 - (28 * P), 4), Cells(459 - (28 * P), 6)).Copy
    Range("D6").PasteSpecial (xlValues)
    Range(Cells(432 - (28 * P), 9), Cells(459 - (28 * P), 11)).Copy
    Range("I6").PasteSpecial (xlValues)
    Range(Cells(432 - (28 * P), 15), Cells(459 - (28 * P), 15)).Copy
    Range("O6").PasteSpecial (xlValues)
    Application.CutCopyMode = False
    Range("D6").Select
End Sub

Sub PeriodAfter()
    P = Range("AB18")
    If P = 0 Then NewPeriod: Exit Sub
    Range("D6:F33").Copy
    Cells(432 - (28 * P), 4).PasteSpecial (xlValues)
    Range("I6:K33").Copy
    Cells(432 - (28 * P), 9).PasteSpecial (xlValues)
    Range("O6:O33").Copy
    Cells(432 - (28 * P), 15).PasteSpecial (xlValues)
    Range("V6:Y33").Copy
    Cells(432 - (28 * P), 22).PasteSpecial (xlValues)
    Range("AB18") = P - 1: P = P - 1
    ActiveSheet.DrawingObjects("Button 2").Caption = "<--  Previous Period"
    ActiveSheet.DrawingObjects("Button 3").Caption = "Next 28 Day Period  -->  "
    ActiveSheet.DrawingObjects("Button 1").Caption = "Current Period = " & -P
    If P = 0 Then ActiveSheet.DrawingObjects("Button 3").Caption = "New 28 Day Period  -->  "
    Range(Cells(432 - (28 * P), 4), Cells(459 - (28 * P), 6)).Copy
    Range("D6").PasteSpecial (xlValues)
    Range(Cells(432 - (28 * P), 9), Cells(459 - (28 * P), 11)).Copy
    Range("I6").PasteSpecial (xlValues)
    Range(Cells(432 - (28 * P), 15), Cells(459 - (28 * P), 15)).Copy
    Range("O6").PasteSpecial (xlValues)
    Application.CutCopyMode = False
    Range("D6").Select
End Sub
 
Upvote 0
Thanks for that, do you want the button you copied to act on the sheet it's on, or the sheet you copied it from?
 
Upvote 0
Paramedic FTL Duty Hours.xls
ABCDEFGHIJKLMNO
1Louise CoxDuty and Flying Hours Record SheetFrom6 Oct to 2 Nov 2020
2
3DUTY HOURSFLYING HOURSOFF
4Day NoDayDateDuty Period28 Day Total7 Day TotalFlight Times28 Day Total7 Day Total14 Day TotalDuty / Remarks
5StartFinishHoursFirst T/OLast LdgFly Hrs
61Tue06-Oct08:0018:0010:00180:0050:000:000:000Training
72Wed07-Oct08:0018:0010:00180:0050:000:000:000Training
83Thu08-Oct08:0018:0010:00180:0050:000:000:000Training
94Fri09-Oct08:0018:0010:00190:0050:000:000:000Training
105Sat10-Oct190:0050:000:000:000
116Sun11-Oct180:0050:000:000:000
127Mon12-Oct08:0018:0010:00180:0050:000:000:000Training
138Tue13-Oct08:0018:0010:00180:0050:000:000:000Training
149Wed14-Oct170:0040:000:000:000
1510Thu15-Oct08:0018:0010:00180:0040:000:000:000Training
1611Fri16-Oct08:0018:0010:00180:0040:000:000:000Training
Louise Cox
Cell Formulas
RangeFormula
M1M1=C6
O1O1=" to " & TEXT(C33,"d mmm yyyy")
B6:B16B6=VLOOKUP(WEEKDAY(C6),$AA$6:$AB$12,2)
C6C6=AB16-(AB18*28)
C7:C16C7=C6+1
G6G6=SUM(F$6:F6,AD6:AD$33)
H6:H11H6=SUM(F$6:F6,AD28:AD$33)
G7:G16G7=SUM(F$6:F7,AD8:AD$33)
H12:H16,M12:M16H12=SUM(F6:F12)
L6L6=SUM(K$6:K6,AE6:AE$33)
M6:M11M6=SUM(K$6:K6,AE28:AE$33)
N6:N16N6=SUM(Y$6:Y6,AF21:AF$33)
L7:L16L7=SUM(K$6:K7,AE8:AE$33)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
N6:N33Cell Value<3textYES
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

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