Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 12
Default lookup formatted cell

I am trying to write a formula similar to vlookup. Basically, what I want
to do is write a formula or something that will look at a cell and if that
cell is highlighted blue, then the cell equals yes; if not then cell equals
no. This worksheet has over 10000 rows. Is this possible? I was looking
into writing a macro or something, but I don't know where to start.

Thanks
Kim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default lookup formatted cell

Hi Kim,

Here is some code that might work for you. It will look to see if each Cell
in range A1:A10000 has an interior ColorIndex of 5 (BLUE). If it does then it
will set the value of that cell to "Yes", otherwise "No". Simply change the
name of the sheet "Sheet1" and the range "A1:A10000" to meet your needs.

Hope it helps.

Regards,
James

Sub SetYesNoValue()
'DECLARATIONS
'------------
Dim wks As Worksheet
Dim rng As Range

'INITIALIZE
'----------
On Error GoTo ErrHandler
' Change the name of "Sheet1" below to your worksheet name.
Set wks = ThisWorkbook.Worksheets("Sheet1")

'MAIN BODY
'---------
Application.ScreenUpdating = False
' Change the value of the range "A1:A10000" to your range.
For Each rng In wks.Range("A1:A10000")
If rng.Interior.ColorIndex = 5 Then ' ColorIndex 5 = BLUE
rng.Value = "Yes"
Else
rng.Value = "No"
End If
Next rng
Application.ScreenUpdating = True
MsgBox "DONE"

'WRAP-UP
'-------
GoSub CleanUp
Exit Sub

'CLEAN-UP
'--------
CleanUp:
Application.ScreenUpdating = True
Set wks = Nothing
Set rng = Nothing
Return

'ERROR HANDLER
'-------------
ErrHandler:
MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf &
Err.Description, _
vbOKOnly + vbInformation, "SetYesNoValue()"
GoSub CleanUp
End Sub

"Kim" wrote:

I am trying to write a formula similar to vlookup. Basically, what I want
to do is write a formula or something that will look at a cell and if that
cell is highlighted blue, then the cell equals yes; if not then cell equals
no. This worksheet has over 10000 rows. Is this possible? I was looking
into writing a macro or something, but I don't know where to start.

Thanks
Kim



  #3   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 12
Default lookup formatted cell

James,
The blue highighted cells already contain values, so changing the values to
yes will not help. Is there a way to have an adjacent cell equal to yes.
Basically, what I want is similar to an if statement. If cell XX is
highlighted blue, then yes, if not, then no.

Thanks
Kim

"JS2004R6" wrote in message
...
Hi Kim,

Here is some code that might work for you. It will look to see if each
Cell
in range A1:A10000 has an interior ColorIndex of 5 (BLUE). If it does then
it
will set the value of that cell to "Yes", otherwise "No". Simply change
the
name of the sheet "Sheet1" and the range "A1:A10000" to meet your needs.

Hope it helps.

Regards,
James

Sub SetYesNoValue()
'DECLARATIONS
'------------
Dim wks As Worksheet
Dim rng As Range

'INITIALIZE
'----------
On Error GoTo ErrHandler
' Change the name of "Sheet1" below to your worksheet name.
Set wks = ThisWorkbook.Worksheets("Sheet1")

'MAIN BODY
'---------
Application.ScreenUpdating = False
' Change the value of the range "A1:A10000" to your range.
For Each rng In wks.Range("A1:A10000")
If rng.Interior.ColorIndex = 5 Then ' ColorIndex 5 = BLUE
rng.Value = "Yes"
Else
rng.Value = "No"
End If
Next rng
Application.ScreenUpdating = True
MsgBox "DONE"

'WRAP-UP
'-------
GoSub CleanUp
Exit Sub

'CLEAN-UP
'--------
CleanUp:
Application.ScreenUpdating = True
Set wks = Nothing
Set rng = Nothing
Return

'ERROR HANDLER
'-------------
ErrHandler:
MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf &
Err.Description, _
vbOKOnly + vbInformation, "SetYesNoValue()"
GoSub CleanUp
End Sub

"Kim" wrote:

I am trying to write a formula similar to vlookup. Basically, what I
want
to do is write a formula or something that will look at a cell and if
that
cell is highlighted blue, then the cell equals yes; if not then cell
equals
no. This worksheet has over 10000 rows. Is this possible? I was looking
into writing a macro or something, but I don't know where to start.

Thanks
Kim





  #4   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 12
Default lookup formatted cell

I wrote a custom function in VBA that worked

Function blue(cell)
If cell.Range("A1").Interior.ColorIndex = 5 Then
blue = "Yes"
Else
blue = "No"
End If
End Function

Thanks Again James

Unfortunately, I keep getting a
"Kim" wrote in message
...
James,
The blue highighted cells already contain values, so changing the values
to yes will not help. Is there a way to have an adjacent cell equal to
yes. Basically, what I want is similar to an if statement. If cell XX is
highlighted blue, then yes, if not, then no.

Thanks
Kim

"JS2004R6" wrote in message
...
Hi Kim,

Here is some code that might work for you. It will look to see if each
Cell
in range A1:A10000 has an interior ColorIndex of 5 (BLUE). If it does
then it
will set the value of that cell to "Yes", otherwise "No". Simply change
the
name of the sheet "Sheet1" and the range "A1:A10000" to meet your needs.

Hope it helps.

Regards,
James

Sub SetYesNoValue()
'DECLARATIONS
'------------
Dim wks As Worksheet
Dim rng As Range

'INITIALIZE
'----------
On Error GoTo ErrHandler
' Change the name of "Sheet1" below to your worksheet name.
Set wks = ThisWorkbook.Worksheets("Sheet1")

'MAIN BODY
'---------
Application.ScreenUpdating = False
' Change the value of the range "A1:A10000" to your range.
For Each rng In wks.Range("A1:A10000")
If rng.Interior.ColorIndex = 5 Then ' ColorIndex 5 = BLUE
rng.Value = "Yes"
Else
rng.Value = "No"
End If
Next rng
Application.ScreenUpdating = True
MsgBox "DONE"

'WRAP-UP
'-------
GoSub CleanUp
Exit Sub

'CLEAN-UP
'--------
CleanUp:
Application.ScreenUpdating = True
Set wks = Nothing
Set rng = Nothing
Return

'ERROR HANDLER
'-------------
ErrHandler:
MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf &
Err.Description, _
vbOKOnly + vbInformation, "SetYesNoValue()"
GoSub CleanUp
End Sub

"Kim" wrote:

I am trying to write a formula similar to vlookup. Basically, what I
want
to do is write a formula or something that will look at a cell and if
that
cell is highlighted blue, then the cell equals yes; if not then cell
equals
no. This worksheet has over 10000 rows. Is this possible? I was
looking
into writing a macro or something, but I don't know where to start.

Thanks
Kim







  #5   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 12
Default lookup formatted cell

I wrote a custom function in VBA that worked

Function blue(cell)
If cell.Range("A1").Interior.ColorIndex = 5 Then
blue = "Yes"
Else
blue = "No"
End If
End Function

Thanks Again James

Unfortunately, I keep getting a
"Kim" wrote in message
...
James,
The blue highighted cells already contain values, so changing the values
to yes will not help. Is there a way to have an adjacent cell equal to
yes. Basically, what I want is similar to an if statement. If cell XX is
highlighted blue, then yes, if not, then no.

Thanks
Kim

"JS2004R6" wrote in message
...
Hi Kim,

Here is some code that might work for you. It will look to see if each
Cell
in range A1:A10000 has an interior ColorIndex of 5 (BLUE). If it does
then it
will set the value of that cell to "Yes", otherwise "No". Simply change
the
name of the sheet "Sheet1" and the range "A1:A10000" to meet your needs.

Hope it helps.

Regards,
James

Sub SetYesNoValue()
'DECLARATIONS
'------------
Dim wks As Worksheet
Dim rng As Range

'INITIALIZE
'----------
On Error GoTo ErrHandler
' Change the name of "Sheet1" below to your worksheet name.
Set wks = ThisWorkbook.Worksheets("Sheet1")

'MAIN BODY
'---------
Application.ScreenUpdating = False
' Change the value of the range "A1:A10000" to your range.
For Each rng In wks.Range("A1:A10000")
If rng.Interior.ColorIndex = 5 Then ' ColorIndex 5 = BLUE
rng.Value = "Yes"
Else
rng.Value = "No"
End If
Next rng
Application.ScreenUpdating = True
MsgBox "DONE"

'WRAP-UP
'-------
GoSub CleanUp
Exit Sub

'CLEAN-UP
'--------
CleanUp:
Application.ScreenUpdating = True
Set wks = Nothing
Set rng = Nothing
Return

'ERROR HANDLER
'-------------
ErrHandler:
MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf &
Err.Description, _
vbOKOnly + vbInformation, "SetYesNoValue()"
GoSub CleanUp
End Sub

"Kim" wrote:

I am trying to write a formula similar to vlookup. Basically, what I
want
to do is write a formula or something that will look at a cell and if
that
cell is highlighted blue, then the cell equals yes; if not then cell
equals
no. This worksheet has over 10000 rows. Is this possible? I was
looking
into writing a macro or something, but I don't know where to start.

Thanks
Kim










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default lookup formatted cell

Hi Kim,

Yes. You can set the cell to the right of (or left, above, below, etc.) to
Yes/No. Change these lines of code:

From This
rng.Value = "Yes"
To This
rng.Offset(0,1).Value = "Yes"

From This
rng.Value = "No"
To This
rng.Offset(0,1).Value = "No"

Hope that helps.

Cheers,
James

"Kim" wrote:

James,
The blue highighted cells already contain values, so changing the values to
yes will not help. Is there a way to have an adjacent cell equal to yes.
Basically, what I want is similar to an if statement. If cell XX is
highlighted blue, then yes, if not, then no.

Thanks
Kim

"JS2004R6" wrote in message
...
Hi Kim,

Here is some code that might work for you. It will look to see if each
Cell
in range A1:A10000 has an interior ColorIndex of 5 (BLUE). If it does then
it
will set the value of that cell to "Yes", otherwise "No". Simply change
the
name of the sheet "Sheet1" and the range "A1:A10000" to meet your needs.

Hope it helps.

Regards,
James

Sub SetYesNoValue()
'DECLARATIONS
'------------
Dim wks As Worksheet
Dim rng As Range

'INITIALIZE
'----------
On Error GoTo ErrHandler
' Change the name of "Sheet1" below to your worksheet name.
Set wks = ThisWorkbook.Worksheets("Sheet1")

'MAIN BODY
'---------
Application.ScreenUpdating = False
' Change the value of the range "A1:A10000" to your range.
For Each rng In wks.Range("A1:A10000")
If rng.Interior.ColorIndex = 5 Then ' ColorIndex 5 = BLUE
rng.Value = "Yes"
Else
rng.Value = "No"
End If
Next rng
Application.ScreenUpdating = True
MsgBox "DONE"

'WRAP-UP
'-------
GoSub CleanUp
Exit Sub

'CLEAN-UP
'--------
CleanUp:
Application.ScreenUpdating = True
Set wks = Nothing
Set rng = Nothing
Return

'ERROR HANDLER
'-------------
ErrHandler:
MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf &
Err.Description, _
vbOKOnly + vbInformation, "SetYesNoValue()"
GoSub CleanUp
End Sub

"Kim" wrote:

I am trying to write a formula similar to vlookup. Basically, what I
want
to do is write a formula or something that will look at a cell and if
that
cell is highlighted blue, then the cell equals yes; if not then cell
equals
no. This worksheet has over 10000 rows. Is this possible? I was looking
into writing a macro or something, but I don't know where to start.

Thanks
Kim






  #7   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 12
Default lookup formatted cell

Thanks Again James. I've been trying to teach myself excel VBA/macro
writing - still a newbie.

Kim

"JS2004R6" wrote in message
...
Hi Kim,

Yes. You can set the cell to the right of (or left, above, below, etc.) to
Yes/No. Change these lines of code:

From This
rng.Value = "Yes"
To This
rng.Offset(0,1).Value = "Yes"

From This
rng.Value = "No"
To This
rng.Offset(0,1).Value = "No"

Hope that helps.

Cheers,
James

"Kim" wrote:

James,
The blue highighted cells already contain values, so changing the values
to
yes will not help. Is there a way to have an adjacent cell equal to yes.
Basically, what I want is similar to an if statement. If cell XX is
highlighted blue, then yes, if not, then no.

Thanks
Kim

"JS2004R6" wrote in message
...
Hi Kim,

Here is some code that might work for you. It will look to see if each
Cell
in range A1:A10000 has an interior ColorIndex of 5 (BLUE). If it does
then
it
will set the value of that cell to "Yes", otherwise "No". Simply change
the
name of the sheet "Sheet1" and the range "A1:A10000" to meet your
needs.

Hope it helps.

Regards,
James

Sub SetYesNoValue()
'DECLARATIONS
'------------
Dim wks As Worksheet
Dim rng As Range

'INITIALIZE
'----------
On Error GoTo ErrHandler
' Change the name of "Sheet1" below to your worksheet name.
Set wks = ThisWorkbook.Worksheets("Sheet1")

'MAIN BODY
'---------
Application.ScreenUpdating = False
' Change the value of the range "A1:A10000" to your range.
For Each rng In wks.Range("A1:A10000")
If rng.Interior.ColorIndex = 5 Then ' ColorIndex 5 = BLUE
rng.Value = "Yes"
Else
rng.Value = "No"
End If
Next rng
Application.ScreenUpdating = True
MsgBox "DONE"

'WRAP-UP
'-------
GoSub CleanUp
Exit Sub

'CLEAN-UP
'--------
CleanUp:
Application.ScreenUpdating = True
Set wks = Nothing
Set rng = Nothing
Return

'ERROR HANDLER
'-------------
ErrHandler:
MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf &
Err.Description, _
vbOKOnly + vbInformation, "SetYesNoValue()"
GoSub CleanUp
End Sub

"Kim" wrote:

I am trying to write a formula similar to vlookup. Basically, what I
want
to do is write a formula or something that will look at a cell and if
that
cell is highlighted blue, then the cell equals yes; if not then cell
equals
no. This worksheet has over 10000 rows. Is this possible? I was
looking
into writing a macro or something, but I don't know where to start.

Thanks
Kim








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
linking a text formatted cell to a formula cell lacy Excel Discussion (Misc queries) 1 May 22nd 09 03:19 PM
Why do I get this ###### instead of 11:00 p.m. in formatted cell? new user New Users to Excel 3 September 15th 08 09:05 PM
Formatted Cell abiamonte Excel Discussion (Misc queries) 1 July 29th 08 10:04 PM
VLOOKUP using a number as text to "lookup" a match formatted in a Maxine Excel Worksheet Functions 4 June 30th 08 03:03 AM
Converting 'General' formatted cells to Text formatted cell using. Zahid Khan Excel Worksheet Functions 1 March 12th 05 07:13 PM


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

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

About Us

"It's about Microsoft Excel"