Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Looping Question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Looping Question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Looping Question

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping Question MWS Excel Discussion (Misc queries) 1 June 5th 06 07:23 PM
Looping Question (I think?) MWS Excel Programming 2 October 27th 04 02:09 PM
Looping Question MWS Excel Programming 0 October 27th 04 01:49 PM
Looping question Rune_Daub[_8_] Excel Programming 1 November 8th 03 04:06 PM
Looping Question? Michael168[_56_] Excel Programming 2 November 7th 03 12:45 PM


All times are GMT +1. The time now is 07:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"