Looping Question
Hi,
Try the following (just review the 'CHANGE HERE' section):
'------------------------------------------------------------
Sub test()
Dim rgData As Range
Dim DestRange As Range
Dim DestCol As String
Dim f As String 'formula
'---- CHANGE HERE -----
Set rgData = ActiveSheet.Range("H6") 'first cell of data in H
DestCol = "G" 'where to write the formulas: column letter
f = "=MID(H6,FIND("","",H6,FIND("","",H6)+1)+1,3)" 'formula for 1st cell
'----------------------
'range of data in H
Set rgData = Range(rgData, rgData.EntireColumn.Cells(65536).End(xlUp))
'col G
Set DestRange = Range(DestCol & ":" & DestCol)
'G cells matching rgData
Set DestRange = Application.Intersect(DestRange, rgData.EntireRow)
'Apply formula in one single shot: reference updates
automatically(H6,H7,...)
DestRange.Formula = f
End Sub
'------------------------------------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com
"MWS" wrote:
Hello, I'm having difficulty writing a macro to enter the following formula
in cell G6:
=MID(H6,FIND(",",H6,FIND(",",H6)+1)+1,3)
and continue to add the same formula in subsequent rows of column G, until
there is no longer any values in column H.
Any and All Help Is Appreciated - Thank You
|