Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Hi need help with RowSelection

Im sure this is an elementary question but I'd rather ask than to spend two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15
i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted rows??

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 77
Default Hi need help with RowSelection

Hi M& M

You could try using a toggle button instead of a cmd btn and use the same
procedure that you wrote, and then set the colorindex to 0 to change it back
to 'unhighlighted'. Or put in another cmd btn and use your code but change
the colorindex to 0.

hth

BigPig

"M&M" wrote:

Im sure this is an elementary question but I'd rather ask than to spend two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15
i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted rows??

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Hi need help with RowSelection

Thank you for your fast response! I will do just that thanks

"BigPig" wrote:

Hi M& M

You could try using a toggle button instead of a cmd btn and use the same
procedure that you wrote, and then set the colorindex to 0 to change it back
to 'unhighlighted'. Or put in another cmd btn and use your code but change
the colorindex to 0.

hth

BigPig

"M&M" wrote:

Im sure this is an elementary question but I'd rather ask than to spend two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15
i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted rows??

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Hi need help with RowSelection

Im sure this is an elementary question but I'd rather ask than to spend
two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15


Changing the above line to this...

Cells(i, 1).EntireRow.Interior.ColorIndex = -4127 - Cells(i,
1).EntireRow.Interior.ColorIndex

will toggle the shading. The -4127 value is derived by adding your color
index value of 15 to the default color index of -4142.

Rick




i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted
rows??


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Hi need help with RowSelection

Sub ShadingMacro()
Static fSet As Boolean
Dim iLastRow As Long
With ActiveSheet
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With Rows("1:" & iLastRow)
If fSet Then
.Interior.ColorIndex = 0
Else
.Interior.ColorIndex = 15
End If
End With
fSet = Not fSet
End With
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"M&M" wrote in message
...
Thank you for your fast response! I will do just that thanks

"BigPig" wrote:

Hi M& M

You could try using a toggle button instead of a cmd btn and use the same
procedure that you wrote, and then set the colorindex to 0 to change it
back
to 'unhighlighted'. Or put in another cmd btn and use your code but
change
the colorindex to 0.

hth

BigPig

"M&M" wrote:

Im sure this is an elementary question but I'd rather ask than to spend
two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15
i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted
rows??





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Hi need help with RowSelection

Just to give you the "theory" behind my posting... if you have two numbers
you wish to toggle between, simply subtract the variable from the sum of
those two numbers. For example.

Const Num1 = 17
Const Num2 = 43
Const Sum = Num1 + Num2
' Initialize the variable to one of these values
If Variable < Num1 And Variable < Num2 Then Variable = Num1
Variable = Sum - Variable

Every time you execute the above code, the Variable will toggle between 17
(Num1) and 43 (Num2). If you think about it, this is obvious as the "toggle
line" is really this

Variable = (Num1 + Num2) - Variable

where Variable is either Num1 or Num2... subtracting one number from the sum
yields the other. That is,

(Num1 + Num2) - Num1 == Num2

(Num1 + Num2) - Num2 == Num1

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Im sure this is an elementary question but I'd rather ask than to spend
two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15


Changing the above line to this...

Cells(i, 1).EntireRow.Interior.ColorIndex = -4127 - Cells(i,
1).EntireRow.Interior.ColorIndex

will toggle the shading. The -4127 value is derived by adding your color
index value of 15 to the default color index of -4142.

Rick




i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted
rows??



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Hi need help with RowSelection

That 0 should be xlColorindexNone

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Bob Phillips" wrote in message
...
Sub ShadingMacro()
Static fSet As Boolean
Dim iLastRow As Long
With ActiveSheet
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With Rows("1:" & iLastRow)
If fSet Then
.Interior.ColorIndex = 0
Else
.Interior.ColorIndex = 15
End If
End With
fSet = Not fSet
End With
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"M&M" wrote in message
...
Thank you for your fast response! I will do just that thanks

"BigPig" wrote:

Hi M& M

You could try using a toggle button instead of a cmd btn and use the
same
procedure that you wrote, and then set the colorindex to 0 to change it
back
to 'unhighlighted'. Or put in another cmd btn and use your code but
change
the colorindex to 0.

hth

BigPig

"M&M" wrote:

Im sure this is an elementary question but I'd rather ask than to
spend two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15
i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted
rows??





  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Hi need help with RowSelection

Thanks to YOu all!!!!!
Greatly appreciate all of your support. Now theres another question I have.
A userform and when building this there is a image icon to input an image.
for some reason it seems that I cannot simply copy and paste an image into
the userform

How can I do this





"Rick Rothstein (MVP - VB)" wrote:

Just to give you the "theory" behind my posting... if you have two numbers
you wish to toggle between, simply subtract the variable from the sum of
those two numbers. For example.

Const Num1 = 17
Const Num2 = 43
Const Sum = Num1 + Num2
' Initialize the variable to one of these values
If Variable < Num1 And Variable < Num2 Then Variable = Num1
Variable = Sum - Variable

Every time you execute the above code, the Variable will toggle between 17
(Num1) and 43 (Num2). If you think about it, this is obvious as the "toggle
line" is really this

Variable = (Num1 + Num2) - Variable

where Variable is either Num1 or Num2... subtracting one number from the sum
yields the other. That is,

(Num1 + Num2) - Num1 == Num2

(Num1 + Num2) - Num2 == Num1

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Im sure this is an elementary question but I'd rather ask than to spend
two
hours trying to figure it out.

I have the macro below:

Sub ShadingMacro()
Dim i As Integer
i = 2
Do Until IsEmpty(Cells(i, 1))
Cells(i, 1).EntireRow.Interior.ColorIndex = 15


Changing the above line to this...

Cells(i, 1).EntireRow.Interior.ColorIndex = -4127 - Cells(i,
1).EntireRow.Interior.ColorIndex

will toggle the shading. The -4127 value is derived by adding your color
index value of 15 to the default color index of -4142.

Rick




i = i + 2
Loop
End Sub


How do I click that same command button again to undo the highlighted
rows??




  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 77
Default Hi need help with RowSelection

Hi M&M,

First save the image as either bitmap or jpeg. In userform properties look
for picture. Click on the three little dots (...) to the right...
Then look for 'PicturePosition' to stretch, tile or whatever. Also, to
delete the picture, click in the field next to 'Picture' and hit the delete
key.

hth

BigPig

"M&M" wrote:

Thanks to YOu all!!!!!
Greatly appreciate all of your support. Now theres another question I have.
A userform and when building this there is a image icon to input an image.
for some reason it seems that I cannot simply copy and paste an image into
the userform

How can I do this


  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Hi need help with RowSelection

Thanks once more. Deeply appreciate it. Have a wonderful day

"BigPig" wrote:

Hi M&M,

First save the image as either bitmap or jpeg. In userform properties look
for picture. Click on the three little dots (...) to the right...
Then look for 'PicturePosition' to stretch, tile or whatever. Also, to
delete the picture, click in the field next to 'Picture' and hit the delete
key.

hth

BigPig

"M&M" wrote:

Thanks to YOu all!!!!!
Greatly appreciate all of your support. Now theres another question I have.
A userform and when building this there is a image icon to input an image.
for some reason it seems that I cannot simply copy and paste an image into
the userform

How can I do this


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



All times are GMT +1. The time now is 07:20 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"