Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default range loop? help

I have a series of queries that uses a range to autofilter.

This works by working through a list in cells C8 to C34.

At present I use the code detailed below but know there must be a way of
excel working through this list more intelligently i.e. not having to name
the cell to copy paste but work through the range in order.

-----------------------------------------------------------------------------------------
Sub EditPt2()

'Filter each district

'District 1
Sheets("Control").Select
Range("C8").Select
Selection.Copy
Range("C6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Call FilterDistricts

'District 2
Sheets("Control").Select
Range("C9").Select
Selection.Copy
Range("C6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Call FilterDistricts

etc etc etc.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default range loop? help

Not sure what the procedure does; but try the below loop...


Dim lngRow As Long

Sheets("Control").Select
For lngRow = 8 To 34
Range("C6") = Range("C" & lngRow).Value
Call FilterDistricts
Next

--
Jacob (MVP - Excel)


"fishy" wrote:

I have a series of queries that uses a range to autofilter.

This works by working through a list in cells C8 to C34.

At present I use the code detailed below but know there must be a way of
excel working through this list more intelligently i.e. not having to name
the cell to copy paste but work through the range in order.

-----------------------------------------------------------------------------------------
Sub EditPt2()

'Filter each district

'District 1
Sheets("Control").Select
Range("C8").Select
Selection.Copy
Range("C6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Call FilterDistricts

'District 2
Sheets("Control").Select
Range("C9").Select
Selection.Copy
Range("C6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Call FilterDistricts

etc etc etc.

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
loop through cells in a range and pick up corresponding cell values in another range [email protected] Excel Programming 9 October 19th 06 05:11 AM
Add a Range to an existing Range in a loop? Mick Excel Programming 3 June 18th 05 06:12 AM
Loop through a range James Excel Programming 1 April 8th 05 07:59 PM
Loop in a Range aksel børve Excel Programming 2 March 8th 05 06:40 PM
Loop through a range Fred[_21_] Excel Programming 6 October 22nd 04 10:45 PM


All times are GMT +1. The time now is 08:44 PM.

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

About Us

"It's about Microsoft Excel"