ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Loops (https://www.excelbanter.com/excel-discussion-misc-queries/144158-loops.html)

SaraJane

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?


Nick Hodge

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?



Otto Moehrbach

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?




SaraJane

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?



Nick Hodge

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?




Gord Dibben

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?



SaraJane

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


SaraJane

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


SaraJane

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


SaraJane

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


Bernie Deitrick

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




Gord Dibben

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?




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com