I hope your holidays were terrific and you are looking forward to 2014!
I am having some difficulty combining my code in different sheets.
I have attached a work sheet with all of this but I will start by saying this seems to be one area where I am having difficulty.
Here is the code:
Private Sub Worksheet_Calculate()
Dim rngUpdate As Range
Dim sFormula As String
On Error GoTo NoRangeFound
sFormula = "If('" & Me.Name & "'!H10:H1000=1,Row('" & Me.Name & "'!H10:H1000)&"":""&Row('" & Me.Name & "'!H10:H1000))"
Set rngUpdate = Me.Range(Join(Filter(Application.Transpose(Evaluate(sFormula)), False, False), ","))
If Not rngUpdate Is Nothing Then
Set rngUpdate = Union(rngUpdate, rngUpdate)
Intersect(rngUpdate.EntireRow, Columns("I")).Value = 1
Set rngUpdate = Nothing
What it does in this case is if I have a formual in h that is: =if(f10>g10, 1, 0). This formula is copied down the entire range.
What the code does is if the formula evaluates to "1" then another "1" appears in the corresponding cell in the "I" column and this triggers the code (see sheet). On its own it works fine.
Now when I do another similar piece of code in another sheet it doesn't quite want to work the way it should. I have to play around with the macros and hit run and do things that I don't want to do whenever that magic "1" appears.
So I think I am having some naming convention problems even though these are both private subs.
In the second part of the code the VBA compiler does not like some of the naming conventions of the variables (I think) between the "brains" and "basic" code. See sheet.
Finally, when I call the sub "placeFlag" the macro box pops up. I just want "placeFlag" to run and can't figure out why. The sub works fine in and of itself, it is in another sheet in the same work book and is not private so I am not sure what the problem might be.
Finally, in the attached sheet I have not included every single other sheet in the workbook because it is some irrelevant to this problem except as the "placeFlag" sub is concerned...but I think I am just doing something silly that I should have learnt by now but have not.
thanks for all of your help!