Thread: Loop problem
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
damorrison[_2_] damorrison[_2_] is offline
external usenet poster
 
Posts: 38
Default Loop problem

heres a couple lines of code to get you started in cleaning this up:
this is not option explicit, so you need to delete option explict from
the modual before you enter this code.
the for next
Sub ForNextTest ()
Range("yourRangeHere").select
For varCounter = 1 to 60
'enter code here
Next
End Sub
This will repeat the code 60 times,

a simple copy/paste code
Sub CopyRange()
Range("A1:B3").Copy Destination:=ActiveCell
End Sub
the code is actually one line
If you are pasting special values like
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
this means the same:
..PasteSpecial xlPasteValues -you don't need all the other garbage that
the macro reader records
you can name your ranges so then you won't have to enter the sheet
name,
hightlite the cell or range you want to name click on the arrow beside
the formula "="
type in a one word name and enter
now when you want to select a range in code enter it something like
this.
Range("namedrange").select Destination:= active cell
Once you have cleaned this up some , lets see it again
Dave!