Macro to copy cell format

Janso

New Member
Joined
Jan 9, 2019
Messages
5
Hi,

I'll explain the purpose of my spreadsheet before I say what I'm trying to achieve as it might make more sense that way.

I've been asked to create a spreadsheet to log when we have cancelled a sales order and why, but in such a way that it will be a visual checklist. I know that there's a checkbox in excel but I don't want to use that if I can avoid it.

So, this brings me onto my macro question. I want to have two buttons on each row, one that I can click to mark that we have cancelled an order and will mark the range of cells on this row in orange (arbitrary colour choice but thought it made sense since that's half the job). I also want one that will then allow me to click to say we have cancelled the raw material order too, which I want to colour in green.

How do I go about doing this? I've tried following a few guides on how to set up macros but I think this might be a bit more advanced than the things I'm looking at. Is it even possible to do this without massive amounts of faffing about?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Would these buttons be in specific columns?
 
Upvote 0
Rather than adding a shed load of buttons to your sheet, how about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Target.column = 10 Then
      Intersect(Me.UsedRange, Target.EntireRow).Interior.ColorIndex = 46
   ElseIf Target.column = 11 Then
      Intersect(Me.UsedRange, Target.EntireRow).Interior.ColorIndex = 43
   End If
   Cancel = True
End Sub
Place this in the relevant sheet module.
Then if you doubleclick col J or col K the row will change colour.
 
Upvote 0
Rather than adding a shed load of buttons to your sheet, how about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Target.column = 10 Then
      Intersect(Me.UsedRange, Target.EntireRow).Interior.ColorIndex = 46
   ElseIf Target.column = 11 Then
      Intersect(Me.UsedRange, Target.EntireRow).Interior.ColorIndex = 43
   End If
   Cancel = True
End Sub
Place this in the relevant sheet module.
Then if you doubleclick col J or col K the row will change colour.

I've tried this but it gives me an error saying that it's unavailable or macros may be disabled - they definitely aren't disabled so I'm not sure what I've done.



I'm not too good with excel so I've probably done something stupid or missed something obvious...
 
Upvote 0
Go into trust centre settings & check that the folder the workbook is in , is in the list of trusted locations.
 
Upvote 0
Hi,
Try this: close the workbook with the vba code, open the workbook again and once it opens you should have a yellow bar above the cells saying that macros have been disabled abd there should be a button next to it named "enable content". Press the button and save changes ctrl+s and it should work.
Regards,
Sebastian
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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