Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank You - It works perfectly and I Appreciate Your Assistance!!!!
"sebastienm" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim iLastRow As Long Dim sFormula As String sFormula = "=MID(H6,FIND("","",H6,FIND("","",H6)+1)+1,3)" iLastRow = Cells(Rows.Count, "H").End(xlUp).Row With Range("G6") .Formula = sFormula .AutoFill .Resize(iLastRow - 5) End With End Sub -- HTH RP (remove nothere from the email address if mailing direct) "MWS" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Looping Question | Excel Discussion (Misc queries) | |||
Looping Question (I think?) | Excel Programming | |||
Looping Question | Excel Programming | |||
Looping question | Excel Programming | |||
Looping Question? | Excel Programming |