Creating macro to perform certain actions based on cell contents
I'm trying to figure out how to develop a macro to analyze the content of a cell and perform different actions based on what is in the cell. To be more specific, let's say I want the macro to go to cell B2 and determine what is in that cell. If it determines that the cell contains the letter A then I want to perform a certain action. However, if it contains the letter B I want it to perform a different action. How would I do this?
Re: Creating macro to perform certain actions based on cell contents
Simple sample code:
Code:
Sub CellCheckProc()
If Sheet1.Cells(1,1) = "A" Then
' Put your code here for A action
End If
If Sheet1.Cells(1,1) = "B" Then
' Put your code here for B action
End If
' Etc., etc.
End Sub
Re: Creating macro to perform certain actions based on cell contents
You can use the simple Between, And & Or commands as well. all work the same. how many cells are you looking at working with? is it one or two specific cells or is it a range?