Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
I have a simple script that works only okay when going in one
direction, putting a strikethrough when on a particular line: With Selection.Font .Strikethrough = True End With I needed to be able to have a script firstly, behave in a toggle fashion - i.e., press the button and the strikethrough is applied, press the button and it's taken off. Then it would be good to have this work on any given line one is on that it puts the strikethrough on that line for the 2 columns in that spreadsheet for that line, columns A and B. What code would do this pls? I have only one spreadsheet that applies a border line with various "attributes", I think they'd be called (certain line style, colour, etc.) but it applies to a top border and no amount of working with the code has yielded what I need. I seem to still be a junior at all this even after all this time! <sheepish grin Thank you! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
On Nov 11, 6:44*am, StargateFan wrote:
I have a simple script that works only okay when going in one direction, putting a strikethrough when on a particular line: * * With Selection.Font * * * * .Strikethrough = True * * End With I needed to be able to have a script firstly, behave in a toggle fashion - i.e., press the button and the strikethrough is applied, press the button and it's taken off. Then it would be good to have this work on any given line one is on that it puts the strikethrough on that line for the 2 columns in that spreadsheet for that line, columns A and B. What code would do this pls? *I have only one spreadsheet that applies a border line with various "attributes", I think they'd be called (certain line style, colour, etc.) but it applies to a top border and no amount of working with the code has yielded what I need. *I seem to still be a junior at all this even after all this time! *<sheepish grin Thank you! Sub togglestrikethru() 'selected cell(s) Selection.Font.Strikethrough = _ Not Selection.Font.Strikethrough End Sub Sub togglestrikethruCOLS() 'columns a:b mr = ActiveCell.Row Cells(mr, 1).Resize(, 2).Font.Strikethrough = _ Not Cells(mr, 1).Resize(, 2).Font.Strikethrough End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
Does one row, two columns - starting from the top left selected cell...
With Selection.Resize(1, 2).Font .Strikethrough = Not .Strikethrough End With -- Jim Cone Portland, Oregon USA http://www.mediafire.com/PrimitiveSoftware .. .. .. "StargateFan" wrote in message ... I have a simple script that works only okay when going in one direction, putting a strikethrough when on a particular line: With Selection.Font .Strikethrough = True End With I needed to be able to have a script firstly, behave in a toggle fashion - i.e., press the button and the strikethrough is applied, press the button and it's taken off. Then it would be good to have this work on any given line one is on that it puts the strikethrough on that line for the 2 columns in that spreadsheet for that line, columns A and B. What code would do this pls? I have only one spreadsheet that applies a border line with various "attributes", I think they'd be called (certain line style, colour, etc.) but it applies to a top border and no amount of working with the code has yielded what I need. I seem to still be a junior at all this even after all this time! <sheepish grin Thank you! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
Those will err with mixed content. I suggest reading one cell only:
Sub A() 'selected cell(s) Selection.Font.Strikethrough = _ Not Selection(1).Font.Strikethrough End Sub Sub B() Selection.Resize(1, 2).Font.Strikethrough = _ Not Selection(1).Font.Strikethrough End Sub Best wishes Harald "Jim Cone" wrote in message ... Does one row, two columns - starting from the top left selected cell... With Selection.Resize(1, 2).Font .Strikethrough = Not .Strikethrough End With -- Jim Cone Portland, Oregon USA http://www.mediafire.com/PrimitiveSoftware . . . "StargateFan" wrote in message ... I have a simple script that works only okay when going in one direction, putting a strikethrough when on a particular line: With Selection.Font .Strikethrough = True End With I needed to be able to have a script firstly, behave in a toggle fashion - i.e., press the button and the strikethrough is applied, press the button and it's taken off. Then it would be good to have this work on any given line one is on that it puts the strikethrough on that line for the 2 columns in that spreadsheet for that line, columns A and B. What code would do this pls? I have only one spreadsheet that applies a border line with various "attributes", I think they'd be called (certain line style, colour, etc.) but it applies to a top border and no amount of working with the code has yielded what I need. I seem to still be a junior at all this even after all this time! <sheepish grin Thank you! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
Harald,
Glad you are still hanging around. Thanks. '-- Jim Cone "Harald Staff" wrote in message . .. Those will err with mixed content. I suggest reading one cell only: Sub A() 'selected cell(s) Selection.Font.Strikethrough = _ Not Selection(1).Font.Strikethrough End Sub Sub B() Selection.Resize(1, 2).Font.Strikethrough = _ Not Selection(1).Font.Strikethrough End Sub Best wishes Harald "Jim Cone" wrote in message ... Does one row, two columns - starting from the top left selected cell... With Selection.Resize(1, 2).Font .Strikethrough = Not .Strikethrough End With -- Jim Cone Portland, Oregon USA http://www.mediafire.com/PrimitiveSoftware |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
I'm so very, very sorry, but on trying out all these suggestions -
they all work lovely, thank you - I realized that I shouldn't make this toggable. Of course, when I tested it, I mis-clicked and saw how too easy it was to reset something that shouldn't be reset. Glad I figured this out now rather than later <g, though. This sheet is to keep track of items that need to get done so we must be absolutely sure that only accomplished items get the strikethrough. So the button should turn the strikethrough on only, after all. And a separate script with value to false can be accessed by the user manually so that taking the strikethrough off is done on purpose and never by mistake. Phew. Good to figure that out. So I thought it would be easy to figure out how to get the vb code to apply the strikethrough to columns A and B on the which one is on but, blunderwoman strikes again, I can't figure it out. I've spent the last 40 minutes on the archives of this ng and nothing. The only spreadsheet I have that applies formatting to a row in a similar manner deals with the borders so I don't know how to change it to deal with the font and text within a cell. So the simple code seems to still be good: With Selection.Font .Strikethrough = True End With Just need to change the above so that strikethrough is applied to columns A and B of the active row. Thanks so much! :oD |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
Sub DoneAlready()
Dim Rw As Long Rw = ActiveCell.Row Range(Cells(Rw, 1), Cells(Rw, 2)).Font.Strikethrough = True End Sub |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
On Nov 12, 10:38 am, "Jim Cone" wrote:
Sub DoneAlready() Dim Rw As Long Rw = ActiveCell.Row Range(Cells(Rw, 1), Cells(Rw, 2)).Font.Strikethrough = True End Sub This works great, thanks! Well, you guys never need worry that I'll be so good I'll be able to join your team!! <lol I tried seeing if I could reuse this for other row functions but I get an error so thought I'd run it by you all to see what in heck I'm doing wrong this time. Dim Rw As Long Rw = ActiveCell.Row Range(Cells(Rw, 1), Cells(Rw, 2)).Font .Strikethrough = True .Bold = True ' .Color = RGB(0, 0, 0) ' change colour to black If I need to change any other attributes, how can I change the above to accommodate any other font changes needed? Thanks much!!! :oD |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
Dim Rw As Long
Rw = ActiveCell.Row With Range(Cells(Rw, 1), Cells(Rw, 2)).Font .Strikethrough = True .Bold = True .Color = RGB(0, 0, 0) ' change colour to black End With Gord Dibben MS Excel MVP On Fri, 12 Nov 2010 08:59:01 -0800 (PST), StargateFan wrote: On Nov 12, 10:38 am, "Jim Cone" wrote: Sub DoneAlready() Dim Rw As Long Rw = ActiveCell.Row Range(Cells(Rw, 1), Cells(Rw, 2)).Font.Strikethrough = True End Sub This works great, thanks! Well, you guys never need worry that I'll be so good I'll be able to join your team!! <lol I tried seeing if I could reuse this for other row functions but I get an error so thought I'd run it by you all to see what in heck I'm doing wrong this time. Dim Rw As Long Rw = ActiveCell.Row Range(Cells(Rw, 1), Cells(Rw, 2)).Font .Strikethrough = True .Bold = True ' .Color = RGB(0, 0, 0) ' change colour to black If I need to change any other attributes, how can I change the above to accommodate any other font changes needed? Thanks much!!! :oD |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
On Nov 12, 12:17 pm, Gord Dibben wrote:
Dim Rw As Long Rw = ActiveCell.Row With Range(Cells(Rw, 1), Cells(Rw, 2)).Font .Strikethrough = True .Bold = True .Color = RGB(0, 0, 0) ' change colour to black End With Gord Dibben MS Excel MVP On Fri, 12 Nov 2010 08:59:01 -0800 (PST), StargateFan wrote: On Nov 12, 10:38 am, "Jim Cone" wrote: Sub DoneAlready() Dim Rw As Long Rw = ActiveCell.Row Range(Cells(Rw, 1), Cells(Rw, 2)).Font.Strikethrough = True End Sub This works great, thanks! Well, you guys never need worry that I'll be so good I'll be able to join your team!! <lol I tried seeing if I could reuse this for other row functions but I get an error so thought I'd run it by you all to see what in heck I'm doing wrong this time. Dim Rw As Long Rw = ActiveCell.Row Range(Cells(Rw, 1), Cells(Rw, 2)).Font .Strikethrough = True .Bold = True ' .Color = RGB(0, 0, 0) ' change colour to black If I need to change any other attributes, how can I change the above to accommodate any other font changes needed? Thanks much!!! :oD Marvellous! Thank you. I added the colour option back in after all and searched for RGB values. I added red to one and black to the other. Works great. Now I also can't accidentally toggle something OFF when it shouldn't be. I might toggle it ON by mistkae but then can manually take strikethrough off if I realized I slip-clicked. Best of both worlds - I have speed in striking through yet can back out if I pressed the button in error. Cheers! :oD |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this into a toggle command? [XL2003]
After a few days working with this file, I "finetuned" the macros so
that they give me the results I need. I'm very sure there's a better way to do these things but these do the job. The first is tied to a button, the second users have to access via the macros menus. ---------------------------------------------------------------------- Sub DONE_Crosses_off_line() ' Columns A:B ActiveSheet.Unprotect 'place at the beginning of the code Dim Rw As Long Rw = ActiveCell.Row ' With Range(Cells(Rw, 1), Cells(Rw, 2)).Font ' Cells(Rw,1) = start cell ; Cells(Rw,2) = end cell With Range(Cells(Rw, 1), Cells(Rw, 2)).Font .Strikethrough = True End With With Range(Cells(Rw, 1), Cells(Rw, 3)).Font .Color = RGB(255, 0, 0) ' change colour to RED .Bold = True End With ActiveSheet.Protect ' place at end of code End Sub ---------------------------------------------------------------------- Sub a_Strikethrough_Remove() ' Columns A:B ActiveSheet.Unprotect 'place at the beginning of the code Dim Rw As Long Rw = ActiveCell.Row ' With Range(Cells(Rw, 1), Cells(Rw, 2)).Font ' Cells(Rw,1) = start cell ; Cells(Rw,2) = end cell With Range(Cells(Rw, 1), Cells(Rw, 2)).Font .Strikethrough = False End With With Range(Cells(Rw, 1), Cells(Rw, 3)).Font .Color = RGB(0, 0, 0) ' change colour back to BLACK .Bold = False End With ActiveSheet.Protect ' place at end of code End Sub ---------------------------------------------------------------------- Thanks. :oD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
toggle or command and how | Excel Programming | |||
Command Button That Will Toggle | Excel Programming | |||
Xl2003: Validation.Add method gives error from Command Button | Excel Programming | |||
Xl2003: Validation.Add method gives error from Command Button | Excel Programming | |||
Toggle command buttons | Excel Programming |