Home > Software engineering >  Turn the VBA code
Turn the VBA code

Time:11-15

How to select the first column at the same time and the second column all cell fill color is black

CodePudding user response:

Sub Test ()
Dim cel As Range, aa As Range
For Each cel In Range (" A, B)
If cel. Interior. ColorIndex=1 Then
If aa Is Nothing Then Set aa=cel Else Set aa=Union (aa, cel)
End the If
Next
If Not aa Is Nothing Then aa. Select
End Sub

CodePudding user response:

The
1/f, reference & gt; _ & amp; lt; S response:
Sub Test ()
Dim cel As Range, aa As Range
For Each cel In Range (" A, B)
If cel. Interior. ColorIndex=1 Then
If aa Is Nothing Then Set aa=cel Else Set aa=Union (aa, cel)
End the If
Next
If Not aa Is Nothing Then aa. Select
End Sub

Don't run after a cell selected, and the code after the operation is very card,
Problem complement, such as A1 to B10 each cell has a numeric value, a few black cell, a few yellow, now want to use the code realization, select the cell fill color is black, your code is not achieve them

CodePudding user response:

Quote: refer to the second floor qq_20320947 response:

A specific area to limit the scope of the change in the RANGE the BuKa, as follows:
Sub Test ()
Dim cel As Range, aa As Range
For Each cel In Range (" A1: B10 ")
If cel. Interior. ColorIndex=1 Then
If aa Is Nothing Then Set aa=cel Else Set aa=Union (aa, cel)
End the If
Next
If Not aa Is Nothing Then aa. Select
End Sub
Is to be able to choose the unless you cell fill color is not pure black to choose which area to change ColorIndex corresponding color digital line, color CRT and the results we can see pictures

CodePudding user response:

Before upstairs from the first one is running, the penultimate is running, see is a selected cell

CodePudding user response:

Sorry, after I run the code, still not achieve them, watch carefully, to find, I is to use conditional formatting first access to the cell's color is black, A1: cell value between B10 according to conditional formatting has set up a cell fill color is black, is now mainly to select black after the conditional formatting Settings, run your code and found the cell through the black can't selected after the conditional formatting Settings, if it is manual filling yourself with a black cell, use your code really can realize, this problem for a long time, also could you please help processing, thank you! Complementary problem should be changed to conditional formatting Settings after cell is black with VBA code how to implement the selected,

CodePudding user response:

reference 5 floor qq_20320947 reply:
sorry, after I run the code, still not achieve them, watch carefully, to find, I is to use conditional formatting first access to the cell's color is black, A1: cell value between B10 according to conditional formatting has set up a cell fill color is black, is now mainly to select black after the conditional formatting Settings, run your code and found the cell through the black can't selected after the conditional formatting Settings, if it is manual filling yourself with a black cell, use your code really can realize, this problem for a long time, also could you please help processing, thank you! Supplementary problems should be changed to conditional formatting Settings after cell is black with VBA code how to implement the selected,
party upload attachments

CodePudding user response:

Try to look at the color right:
 
Sub test ()
Dim objRange As Range
For Each objRange In Sheet1. Range (" A1: B10 ")
The Debug. Print objRange. Interior. Color
Next
End Sub

CodePudding user response:

The
reference 7 floor milaoshu1020 response:
try, look at the color right:
 
Sub test ()
Dim objRange As Range
For Each objRange In Sheet1. Range (" A1: B10 ")
The Debug. Print objRange. Interior. Color
Next
End Sub

The code you??? How to?

CodePudding user response:

You can use this code to check the color of the automatic generation of and you fill color are consistent;

CodePudding user response:

First of all, it is recommended that the original poster to complete problem description: A: B column with conditional formatting according to the data set A different color, needs code for selected A: all the same color in the B cell

CodePudding user response:

refer to the eighth floor qq_20320947 response:
Quote: refer to 7th floor milaoshu1020 response:
try, look at the color right:
 
Sub test ()
Dim objRange As Range
For Each objRange In Sheet1. Range (" A1: B10 ")
The Debug. Print objRange. Interior. Color
Next
End Sub

The code you??? How to?


This is to let you check if all the color of the grid are the same,
Such as RGB (0, 0) is black, can be quite black RGB (5,5,5) look, but it don't think this is the same color

CodePudding user response:

11 references, crispy big ice cream reply:
Quote: refer to the eighth floor qq_20320947 response:

Quote: refer to 7th floor milaoshu1020 response:
try, look at the color right:
 
Sub test ()
Dim objRange As Range
For Each objRange In Sheet1. Range (" A1: B10 ")
The Debug. Print objRange. Interior. Color
Next
End Sub

The code you??? How to?


This is to let you check if all the color of the grid are the same,
Such as RGB (0, 0) is black, can be quite black RGB (5,5,5) look, but it don't think this is the same color


The building Lord said is to use the color of the conditional formatting markup, this in the code to read not to come out

CodePudding user response:

references 9 f milaoshu1020 response:
you can use this code to check the color of the automatic generation of and you fill color are consistent;

The color that's right, it is black, thank you for your help, there are still no research, is to use conditional formatting to set good cell how to select the color, this problem is very difficult!

CodePudding user response:

refer to 12 floor Mickey Mouse yeah reply:
Quote: 11 references, crispy big ice cream reply:

Quote: refer to the eighth floor qq_20320947 response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related