Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto run not working correctly

Status
Not open for further replies.

wafs

Technical User
Jan 17, 2006
112
US
I runt his and it seems to run fine, except that it just keeps going down the rows and not looking at For Each cell In Range("L9:M42"). Any suggestions?


Sub Macro12()
'
' Macro12 Macro
' Macro recorded 4/25/2006 by Wendy Smith
'run the macro did cells change any time a entry is made in a cell in 1244 HT-DOC 12

ThisWorkbook.Worksheets("1244 HT-DOC 12").OnEntry = "DidCellsChange"
End Sub

Sub keycells()
Dim keycells As String
'define which cells should trigger the macro
keycells = "L9:M42"
End Sub

Sub keycellschange()
Dim cell As Object
Dim reportlocation As String
Dim sh As String
Dim strvar As String
Dim p As Integer
Dim m As String

strvar = "N/A"
sh = "1244 HT-DOC 12"
testrange = keycells
p = 7

'if the values in L9:M42 are equal to 0
For Each cell In Range("L9:M42")
p = p + 1
m = p + 1
If cell = 0 Then <---------cell not changing
reportlocation = "R" + m
Sheets(sh).Range(reportlocation) = strvar
Else
cell = xlNone
End If
Next cell
End Sub

 
Looks like Excel VBA. This is a VB6 Modules & Classes forum, so you will do better in the VBA forum (forum707)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Try faq222-2244 and see my answer in thread710-1222309

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top