#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Loops

I am a newby at macros - so be kind! Can I name ranges within a worksheet
and then write a loop so that I can perform the same functions on each range?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,090
Default Loops

SaraJane
Something like this may work for you. You can add as many range names
as you want. HTH Otto
Sub LoopThruNames()
Dim TheName As Variant
For Each TheName In Array("ThisName", "ThatName", "OtherName")
'Code that operates on "TheName", for instance:
MsgBox Range(TheName).Address(0, 0)
Next
End Sub
"SaraJane" <u34526@uwe wrote in message news:72b853dc12db5@uwe...
I am a newby at macros - so be kind! Can I name ranges within a worksheet
and then write a loop so that I can perform the same functions on each
range?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,173
Default Loops

Sara Jane

Give us an idea what you are trying to do specifically

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
web:
www.nickhodge.co.uk
blog (non-tech): www.nickhodge.co.uk/blog/

"SaraJane" <u34526@uwe wrote in message news:72b853dc12db5@uwe...
I am a newby at macros - so be kind! Can I name ranges within a worksheet
and then write a loop so that I can perform the same functions on each
range?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Loops

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many
columns and rows. I want to name each record "well" and then perform the
exact same functions on each of these records. Is that specific enough?

Nick Hodge wrote:
Sara Jane

Give us an idea what you are trying to do specifically

I am a newby at macros - so be kind! Can I name ranges within a worksheet
and then write a loop so that I can perform the same functions on each
range?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,173
Default Loops

Sara Jane

It is tough to know exactly what you have and you've had one suggestion. You
can iterate collections, so for example if you have a range of A1:C100 you
could do this to work on each object in the collection

Dim myCell as Range
For Each myCell in Range("A1:C100")
myCell.Value=MyCell.Value+1
Next myCell

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
web:
www.nickhodge.co.uk
blog (non-tech): www.nickhodge.co.uk/blog/

"SaraJane" <u34526@uwe wrote in message news:72b90906b6d57@uwe...
I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many
columns and rows. I want to name each record "well" and then perform the
exact same functions on each of these records. Is that specific enough?

Nick Hodge wrote:
Sara Jane

Give us an idea what you are trying to do specifically

I am a newby at macros - so be kind! Can I name ranges within a
worksheet
and then write a loop so that I can perform the same functions on each
range?





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Loops

Is there any common factor that differentiates one record from another?

Blank row between?

Same number of rows per set?


Gord Dibben MS Excel MVP

On Fri, 25 May 2007 21:47:58 GMT, "SaraJane" <u34526@uwe wrote:

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many
columns and rows. I want to name each record "well" and then perform the
exact same functions on each of these records. Is that specific enough?

Nick Hodge wrote:
Sara Jane

Give us an idea what you are trying to do specifically

I am a newby at macros - so be kind! Can I name ranges within a worksheet
and then write a loop so that I can perform the same functions on each
range?


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Loops

Yes, one row between record and yes the same number of rows per set

Gord Dibben wrote:
Is there any common factor that differentiates one record from another?

Blank row between?

Same number of rows per set?

Gord Dibben MS Excel MVP

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many

[quoted text clipped - 8 lines]
and then write a loop so that I can perform the same functions on each
range?


--
Sara Jane

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Loops

SaraJane,

It would help to know what 'function' you want to perform on each range.

But, you could loop through the range areas. Try this test macro with the
sheet active:

Sub Test()
Dim myArea As Range
Dim myCells As Range
Dim i As Integer
i = 0
Set myCells = Cells.SpecialCells(xlCellTypeConstants)
MsgBox "There are " & myCells.Areas.Count & " ""wells"" of data"
For Each myArea In myCells.Areas
i = i + 1
MsgBox "Area #" & i & " is in cells " & myArea.Address
Next myArea
End Sub


If this macro appears to count the correct number of 'wells', then we can
apply functions once we know what you want.

HTH,
Bernie
MS Excel MVP




"SaraJane" <u34526@uwe wrote in message news:72baefb8bb50f@uwe...
Yes, one row between record and yes the same number of rows per set

Gord Dibben wrote:
Is there any common factor that differentiates one record from another?

Blank row between?

Same number of rows per set?

Gord Dibben MS Excel MVP

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many

[quoted text clipped - 8 lines]
and then write a loop so that I can perform the same functions on each
range?


--
Sara Jane



  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Loops

Yes, one row between record and yes the same number of rows per set

Gord Dibben wrote:
Is there any common factor that differentiates one record from another?

Blank row between?

Same number of rows per set?

Gord Dibben MS Excel MVP

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many

[quoted text clipped - 8 lines]
and then write a loop so that I can perform the same functions on each
range?


--
Sara Jane

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Loops

Yes, one row between record and yes the same number of rows per set

Gord Dibben wrote:
Is there any common factor that differentiates one record from another?

Blank row between?

Same number of rows per set?

Gord Dibben MS Excel MVP

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many

[quoted text clipped - 8 lines]
and then write a loop so that I can perform the same functions on each
range?


--
Sara Jane



  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Loops

See Bernie's post with code to loop through each set.

As Bernie says"what will you do with each set"?

Transpose to one row per set or?


Gord

On Sat, 26 May 2007 01:25:28 GMT, "SaraJane" <u34526@uwe wrote:

Yes, one row between record and yes the same number of rows per set

Gord Dibben wrote:
Is there any common factor that differentiates one record from another?

Blank row between?

Same number of rows per set?

Gord Dibben MS Excel MVP

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many

[quoted text clipped - 8 lines]
and then write a loop so that I can perform the same functions on each
range?


  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Loops

Yes, one row between record and yes the same number of rows per set

Gord Dibben wrote:
Is there any common factor that differentiates one record from another?

Blank row between?

Same number of rows per set?

Gord Dibben MS Excel MVP

I converted a PDF file to excel. I want to convert this data to a usable
form. Each record (l'll call them indiviidual well data) extends to many

[quoted text clipped - 8 lines]
and then write a loop so that I can perform the same functions on each
range?


--
Sara Jane

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
Loops [email protected] Excel Discussion (Misc queries) 2 October 14th 06 02:52 PM
Loops... Willabo Excel Discussion (Misc queries) 2 June 14th 06 04:08 PM
do loops saravanan Excel Worksheet Functions 0 June 13th 06 10:53 AM
For next loops Kate Excel Discussion (Misc queries) 5 May 22nd 06 01:11 PM
Using For - Next Loops in VB Biomed New Users to Excel 4 March 22nd 05 07:12 PM


All times are GMT +1. The time now is 02:16 PM.

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"