Hello all!
Used MrExcel for a while without having to need an account and I've macro'ed hours of time saved until now... I can't figure this one out...
A little back info, I have datasets with sometimes 10,000-30,000 rows of data (luckily only to column J) formulas are required to manipulate this data, so doing this manually is a bit long winded... and until now its always been done manually (why am I the only one to think this could be easier?) So I'm trying to write a macro to offload the worst of the load and save some sanity...
So the question;
Columns A-E have text and dates in, not relevant at this point so lets ignore them... Easy to manually format these as needed so not relevant and already a macro done for these...
Column F has numbers, only numbers. The important ones...
I'd like to check all of Column F for the value "42", on the rows with cell values of "42" insert a formula five cells to the right, and another one six cells to the right of the cells found on each row...
Sounded a lot simpler to me when I thought of it...
But obviously that's not working, which is why I'm here...
Any ideas on how to achieve this?
Thanks in advance,
Vortensis.
Used MrExcel for a while without having to need an account and I've macro'ed hours of time saved until now... I can't figure this one out...
A little back info, I have datasets with sometimes 10,000-30,000 rows of data (luckily only to column J) formulas are required to manipulate this data, so doing this manually is a bit long winded... and until now its always been done manually (why am I the only one to think this could be easier?) So I'm trying to write a macro to offload the worst of the load and save some sanity...
So the question;
Columns A-E have text and dates in, not relevant at this point so lets ignore them... Easy to manually format these as needed so not relevant and already a macro done for these...
Column F has numbers, only numbers. The important ones...
I'd like to check all of Column F for the value "42", on the rows with cell values of "42" insert a formula five cells to the right, and another one six cells to the right of the cells found on each row...
Sounded a lot simpler to me when I thought of it...
VBA Code:
Sub FormulaOn42s(strSearchQuery As String)
Set SearchRange = ActiveWorkbook.ActiveSheet.Range("F:F")
FindWhat = "42"
Set FoundCells = FindAll(SearchRange:=SearchRange, _
FindWhat:=FindWhat, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
MatchCase:=False, _
BeginsWith:=vbNullString, _
EndsWith:=vbNullString, _
BeginEndCompare:=vbTextCompare)
If FoundCells Is Nothing Then
MsgBox "42 not found."
Else
For Each FoundCell In FoundCells
FoundCell.ActiveCell.Select
ActiveCell.FormulaR1C5 = "=HEX2DEC()+850"
ActiveCell.FormulaR1C6 = "=HEX2DEC()+1125"
Loop
End If
End Sub
But obviously that's not working, which is why I'm here...
Any ideas on how to achieve this?
Thanks in advance,
Vortensis.