Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
toggle or command and how NILELATOR Excel Programming 0 January 10th 08 01:07 AM
Command Button That Will Toggle Paige Excel Programming 10 October 31st 07 12:21 AM
Xl2003: Validation.Add method gives error from Command Button sebt Excel Programming 2 April 5th 07 03:30 PM
Xl2003: Validation.Add method gives error from Command Button sebt Excel Programming 0 April 5th 07 02:41 PM
Toggle command buttons GEB Excel Programming 4 June 23rd 05 08:33 PM


All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"