• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

Initializing a cell after testing the color of another cell from a different column

Hi :I upload an excel spreadsheet into SQL, and of course I loose ALL the cell color attributs...
What is the VBA code to update a column flag after testing another  cell's color ?
Thank you.

0
pfraysse99
Asked:
pfraysse99
  • 5
  • 3
1 Solution
 
SiddharthRoutCommented:
You can use the .Interior.ColoIndex property to check if a cell has color or not for example

If Range("A1").Interior.ColorIndex = 3 Then
    MsgBox "Cell's color is red"
End If

Open in new window


Sid
0
 
pfraysse99Author Commented:
Hi - This is a good start..
I actually want to test the cell string's color ... since default is black, I want to test "NOT Black" ..
Thx
0
 
SiddharthRoutCommented:
In that case use this :)

if Range("A1").Font.ColorIndex <> 1 then

1 is for Default.

Sid
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
pfraysse99Author Commented:
Sid - When I plug this syntax in the EXCEL formula :
=IF(Range("A1").Font.ColorIndex <> 1 , B1="X",B1)
I get Error on [Font.ColorIndex]... ???

0
 
SiddharthRoutCommented:
That is because the code that I gave above is VBA has to be run from VBE.

Sid
0
 
SiddharthRoutCommented:
If you want to use it as a formula then paste this in a module

Function CheckFontColor(ByVal rng As Range) As Long
    CheckFontColor = rng.Font.ColorIndex
End Function

Open in new window


and then use the formula

=IF(CheckFontColor(A1)<>1,B1="X",B1)

Sid
0
 
pfraysse99Author Commented:
it looks like I will make it works...Thank you !
0
 
SiddharthRoutCommented:
Let me know if you are still stuck,

Sid
0
 
TracyVBA DeveloperCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now