Making ranges in a macro dynamic?

sadia1991

New Member
Joined
Aug 10, 2014
Messages
11
Hello!

This is the macro I have recorded:
Rich (BB code):
Range("A1:G1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range("A1:G212").Select
    Selection.Copy
    Windows("arrangement.xlsx").Activate
    Range("A1").Select
    ActiveSheet.Paste
    Range("L1:L55").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("MINING.xlsx").Activate
    Range("RA73:RA127").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Windows("!2014-05-15 experiment").Activate
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlUp
    Range("A1").Select
End Sub
How do I make the ranges in red (above) dynamic?
for the line Range("A1:G212").Select I was trying to select a block of cells (which I can do by pressing ctrl + A and then shift+down arrow OR ctrl+shift+down 12 times then shift+up arrow once)

for the line Range("RA73:RA127").Select I was trying to select a block of cells adjacent to the cell already active in the sheet (the idea is that I would paste a block of cells then repeat the macro and the next block of cells would get pasted in the next column etc.)


Thank you for taking the time to read and respond to my question! Any help is greatly appreciated!
 
Last edited by a moderator:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
You should define the Last Row with data like this:

Code:
[COLOR=#0000ff]Dim[/COLOR] LastRow [COLOR=#0000ff]As Long[/COLOR]

LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row

and then use this variable in your range references:

Code:
[COLOR=#000000]Range("A1:G" & LastRow).Select [/COLOR]

To offset the selection over one column to the right use this:

Code:
Range("RA73:RA127").Offset(, 1).Select

Hopefully this will help. Let me know if you have anymore questions.
 
Last edited:
Upvote 0
Thank you mrmmickle1 for your reply! but I'm really confused, I'm not sure what to look for in the lastrow, I was hoping maybe if I put a sample data here my question would make more sense:

A B C D E F G (column in excel)
[TABLE="width: 448"]
<colgroup><col width="64" span="7" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl63, width: 64"]Start[/TD]
[TD="width: 64"]Date:[/TD]
[TD="width: 64"]06/21/12[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD="class: xl63"]End[/TD]
[TD]Date:[/TD]
[TD]05/15/14[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]Subject:[/TD]
[TD="align: right"]F1O[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]Experiment:[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]Group:[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]Box:[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]Start[/TD]
[TD]Time:[/TD]
[TD="class: xl64, align: right"]11:29:20[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]End[/TD]
[TD]Time:[/TD]
[TD="class: xl64, align: right"]11:58:25[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]MSN: [/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]C:[/TD]
[TD="align: right"]1299[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]A:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]9000[/TD]
[TD="align: right"]750[/TD]
[TD="align: right"]100[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]0.5[/TD]
[TD="align: right"]3000[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]500[/TD]
[TD="align: right"]500[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]B:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]369[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]855[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]15:00[/TD]
[TD="align: right"]0.08[/TD]
[TD="align: right"]3001[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]20:00[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]228[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]198[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]25:00:00[/TD]
[TD="align: right"]200[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]30:00:00[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]96[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]D:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]211.82[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]45[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]362[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]220.15[/TD]
[TD="align: right"]184[/TD]
[TD="align: right"]188[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]E:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]0.17[/TD]
[TD="align: right"]0.29[/TD]
[TD="align: right"]0.22[/TD]
[TD="align: right"]0.12[/TD]
[TD="align: right"]0.22[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]0.04[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]F:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]32.26[/TD]
[TD="align: right"]0.34[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.04[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.07[/TD]
[TD="align: right"]0.08[/TD]
[TD="align: right"]0.1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]0.26[/TD]
[TD="align: right"]0.77[/TD]
[TD="align: right"]0.53[/TD]
[TD="align: right"]0.27[/TD]
[TD="align: right"]0.03[/TD]
[/TR]
[TR]
[TD="class: xl63"]G:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]0.88[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]3.93[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.51[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]2.23[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.87[/TD]
[TD="align: right"]777[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]1.98[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.06[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.51[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]15:00[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.39[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.01[/TD]
[TD="align: right"]777[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]20:00[/TD]
[TD="align: right"]1.71[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.03[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.89[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]25:00:00[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.71[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]1.86[/TD]
[TD="align: right"]777[/TD]
[/TR]
[TR]
[TD="class: xl63"]H:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]0.09[/TD]
[TD="align: right"]0.13[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.49[/TD]
[TD="align: right"]1.25[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]1.37[/TD]
[TD="align: right"]1.75[/TD]
[TD="align: right"]2.31[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.74[/TD]
[TD="align: right"]1.18[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.15[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]15:00[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.72[/TD]
[TD="align: right"]0.91[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.24[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]20:00[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.46[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.54[/TD]
[TD="align: right"]777[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]25:00:00[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.2[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.62[/TD]
[TD="align: right"]0.71[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]30:00:00[/TD]
[TD="align: right"]0.93[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.16[/TD]
[TD="align: right"]777[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]35:00:00[/TD]
[TD="align: right"]0.07[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.48[/TD]
[TD="align: right"]0.58[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]40:00:00[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]0.09[/TD]
[TD="align: right"]0.58[/TD]
[TD="align: right"]0.81[/TD]
[TD="align: right"]777[/TD]
[/TR]
[TR]
[TD="class: xl63"]I:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]30.06[/TD]
[TD="align: right"]0.44[/TD]
[TD="align: right"]0.47[/TD]
[TD="align: right"]0.13[/TD]
[TD="align: right"]0.3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]0.19[/TD]
[TD="align: right"]0.05[/TD]
[TD="align: right"]0.72[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.13[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]0.33[/TD]
[TD="align: right"]0.8[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]0.37[/TD]
[TD="align: right"]0.15[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]15:00[/TD]
[TD="align: right"]2.97[/TD]
[TD="align: right"]0.44[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.32[/TD]
[TD="align: right"]0.39[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]20:00[/TD]
[TD="align: right"]0.28[/TD]
[TD="align: right"]0.19[/TD]
[TD="align: right"]0.92[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]30.14[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]25:00:00[/TD]
[TD="align: right"]0.84[/TD]
[TD="align: right"]0.06[/TD]
[TD="align: right"]0.39[/TD]
[TD="align: right"]0.07[/TD]
[TD="align: right"]0.22[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]30:00:00[/TD]
[TD="align: right"]0.26[/TD]
[TD="align: right"]0.05[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.42[/TD]
[TD="align: right"]0.53[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]35:00:00[/TD]
[TD="align: right"]0.13[/TD]
[TD="align: right"]0.12[/TD]
[TD="align: right"]0.52[/TD]
[TD="align: right"]0.13[/TD]
[TD="align: right"]1.71[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]40:00:00[/TD]
[TD="align: right"]0.48[/TD]
[TD="align: right"]0.26[/TD]
[TD="align: right"]0.13[/TD]
[TD="align: right"]0.87[/TD]
[TD="align: right"]0.13[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]45:00:00[/TD]
[TD="align: right"]0.51[/TD]
[TD="align: right"]0.13[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.99[/TD]
[TD="align: right"]0.07[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]50:00:00[/TD]
[TD="align: right"]0.47[/TD]
[TD="align: right"]0.21[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]777[/TD]
[TD="align: right"]30.83[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]55:00:00[/TD]
[TD="align: right"]0.67[/TD]
[TD="align: right"]0.06[/TD]
[TD="align: right"]0.41[/TD]
[TD="align: right"]0.37[/TD]
[TD="align: right"]0.31[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="class: xl63"]J:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.52[/TD]
[TD="align: right"]0.06[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]0.06[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.4[/TD]
[TD="align: right"]1.01[/TD]
[TD="align: right"]0.42[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]0.17[/TD]
[TD="align: right"]0.55[/TD]
[TD="align: right"]0.12[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]1001[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]15:00[/TD]
[TD="align: right"]39.75[/TD]
[TD="align: right"]0.22[/TD]
[TD="align: right"]0.16[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.05[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]20:00[/TD]
[TD="align: right"]0.32[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.09[/TD]
[TD="align: right"]0.09[/TD]
[TD="align: right"]0.31[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]25:00:00[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.44[/TD]
[TD="align: right"]0.3[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.04[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]30:00:00[/TD]
[TD="align: right"]0.55[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]32.78[/TD]
[TD="align: right"]0.38[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]35:00:00[/TD]
[TD="align: right"]0.06[/TD]
[TD="align: right"]0.12[/TD]
[TD="align: right"]0.86[/TD]
[TD="align: right"]0.13[/TD]
[TD="align: right"]0.57[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]40:00:00[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.5[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.23[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]45:00:00[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]0.72[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.07[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]50:00:00[/TD]
[TD="align: right"]0.37[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.22[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.64[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]55:00:00[/TD]
[TD="align: right"]0.98[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]1001[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]60:00:00[/TD]
[TD="align: right"]38.35[/TD]
[TD="align: right"]0.05[/TD]
[TD="align: right"]1.28[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.46[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]65:00:00[/TD]
[TD="align: right"]1.17[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]33.42[/TD]
[TD="align: right"]0.23[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]70:00:00[/TD]
[TD="align: right"]0.28[/TD]
[TD="align: right"]1.03[/TD]
[TD="align: right"]0.72[/TD]
[TD="align: right"]1.05[/TD]
[TD="align: right"]1001[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]75:00:00[/TD]
[TD="align: right"]0.58[/TD]
[TD="align: right"]0.17[/TD]
[TD="align: right"]0.42[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]0.02[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]80:00:00[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.5[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.21[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]85:00:00[/TD]
[TD="align: right"]0.26[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]33.17[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]90:00:00[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.25[/TD]
[TD="align: right"]0.14[/TD]
[TD="align: right"]0.09[/TD]
[TD="align: right"]0.73[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="class: xl63"]K:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]40.92[/TD]
[TD="align: right"]0.45[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.36[/TD]
[TD="align: right"]0.05[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]0.08[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.08[/TD]
[TD="align: right"]0.24[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]0.23[/TD]
[TD="align: right"]0.08[/TD]
[TD="align: right"]0.08[/TD]
[TD="align: right"]0.32[/TD]
[TD="align: right"]0.09[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]15:00[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]35.76[/TD]
[TD="align: right"]0.29[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.16[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]20:00[/TD]
[TD="align: right"]0.35[/TD]
[TD="align: right"]0.24[/TD]
[TD="align: right"]0.55[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]37.81[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]25:00:00[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.06[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]40.01[/TD]
[TD="align: right"]0.15[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]30:00:00[/TD]
[TD="align: right"]0.72[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.19[/TD]
[TD="align: right"]0.04[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]35:00:00[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]0.49[/TD]
[TD="align: right"]0.06[/TD]
[TD="align: right"]1.62[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]40:00:00[/TD]
[TD="align: right"]0.62[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]0.08[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]45:00:00[/TD]
[TD="align: right"]0.85[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]33.05[/TD]
[TD="align: right"]0.1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]50:00:00[/TD]
[TD="align: right"]0.43[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.03[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]55:00:00[/TD]
[TD="align: right"]0.05[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.04[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]60:00:00[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]1001[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]65:00:00[/TD]
[TD="align: right"]33.25[/TD]
[TD="align: right"]0.3[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.05[/TD]
[TD="align: right"]0.04[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]70:00:00[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.58[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]0.14[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]75:00:00[/TD]
[TD="align: right"]0.25[/TD]
[TD="align: right"]0.47[/TD]
[TD="align: right"]0.04[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]0.03[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]80:00:00[/TD]
[TD="align: right"]0.18[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.54[/TD]
[TD="align: right"]0.04[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]85:00:00[/TD]
[TD="align: right"]0.11[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.24[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.23[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]90:00:00[/TD]
[TD="align: right"]0.74[/TD]
[TD="align: right"]0.24[/TD]
[TD="align: right"]0.28[/TD]
[TD="align: right"]1001[/TD]
[TD="align: right"]0.73[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]95:00:00[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.16[/TD]
[TD="align: right"]0.02[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]0.1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]100:00:00[/TD]
[TD="align: right"]0.14[/TD]
[TD="align: right"]0.05[/TD]
[TD="align: right"]0.07[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.18[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]105:00:00[/TD]
[TD="align: right"]0.1[/TD]
[TD="align: right"]0.03[/TD]
[TD="align: right"]0.26[/TD]
[TD="align: right"]0.19[/TD]
[TD="align: right"]0.2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="class: xl63"]O:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]P:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]0:00[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]5:00[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]10:00[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]15:00[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]-1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65, align: right"]20:00[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl66, align: right"]25:00:00[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]-1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[/TR]
[TR]
[TD]empty row[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]Start[/TD]
[TD]Date:[/TD]
[TD]06/15/12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]End[/TD]
[TD]Date:[/TD]
[TD]05/25/14[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl63"]Subject:[/TD]
[TD="align: right"]F2O[/TD]
[TD][/TD]
[TD] [/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
etc.... the data for the next subject is similar to above (same variables) BUT the variables E: F: G: H: I: J: K: O: and P: can have different number of rows. eg. one subject may have 22 data points in "G:" while another may have 135.

I want to be able to select the whole block for the subject and the empty row between that and the next block. then copy and paste this into another sheet (that extracts the important data and then copy Range("L1:L55") from this 2nd sheet into a 3rd sheet where I'm compiling the data. In the 3rd and final sheet I want to be able to paste the data in adjacent columns automatically (the offset doesn't work because I have to repeat this process many times- a few 1000- and I don't want to always paste it in the column next to "RA73:RA127") :(

I hope this makes sense! I really really appreciate your help. Thank you so so much for taking the time to read this.
 
Upvote 0
sadia1991,

It's difficult to decipher what is going on based on the sample data being formatted funny in Post # 3, but I think you want to do something like this. It will increment through columns one at a time up to Column 550... :


Code:
[COLOR=#0000ff]Sub [/COLOR]Test()

     [COLOR=#0000ff]  Dim[/COLOR] i [COLOR=#0000ff]As Integer[/COLOR]

    [COLOR=#0000ff]   For[/COLOR] i = 469 [COLOR=#0000ff]To[/COLOR] 550 [COLOR=#0000ff]Step[/COLOR] 1 [COLOR=#008000]'469 signifies Column RA the next selection will be Column RB (470)[/COLOR]

                Range(Cells(73, i), Cells(127, i)).Offset(, 1).Select

[COLOR=#008000]           'Your Paste Data Code Here[/COLOR]

     [COLOR=#0000ff]  Next[/COLOR] i

[COLOR=#0000ff]End Sub[/COLOR]

I am confused as to how your data is laid out. If you can get a better example of the data I can probably help you further.

Do you know you many iterations you need?
 
Upvote 0
This is what the data looks like: (the different variables E: F: G: H: I: J: K: O: and P: can have different number of rows.)
https://drive.google.com/file/d/0B5d-7iW5ZlFwTjFlY1pfRUxYMEk/edit?usp=sharing

I want to be able to select the whole block for each 'subject' and the empty row right below it (everything in black border in the above file). then copy and paste this into another sheet (that extracts the important data and then copy Range"L1:L55" ( this files gives me a single column of 55 cells that I copy) from this 2nd sheet into a 3rd sheet where I'm compiling the data.

In the 3rd sheet I want to be able to paste the data in adjacent columns, sample sheet here:
https://drive.google.com/file/d/0B5d-7iW5ZlFwY3YtdF9OR2Vzd1U/edit?usp=sharing
so if I already had the first 2 columns of data i'd want the next column in C10:C64, and the next in D10:D64 etc...

I need to repeat this macro at least 5000 times. would that change the code in your previous reply?

Thank you so so much for helping me out!
 
Upvote 0
update!!
I found a way to copy the data from the first file!! :) using
Code:
Range("$A$1").CurrentRegion.Select

now I need to figure out how to paste it in the correct position in the 3rd file!

so sorry for taking up so much of your time. really appreciate all your help!
 
Upvote 0
sadia1991,

I got a chance to look at your files. I had a few questions.

So you want to copy and paste this data in blocks. It appears to me that one row above the Third occurrence of the word "Start" in column A could define a block. (Is This Correct?) If so this link may prove useful: Find Nth Occurance Also Is a block always the same number of rows? Say 100 rows? (The main importance is if the number is static....

So when you say paste this data into another sheet what is the sheet named? Is this a calculation sheet? Once the data is pasted to this calculation **** I assume it spits out numbers in column L1:L55? You want to copy this data into a brand new sheet until you run out of subjects to complete this process on?

How many subjects to you think you have? 5000? Anyway to get a solid number?

I think I may be able to help you with your task. I just need to drill down the specifics of the process so I can understand what you would like for an end result.....
 
Upvote 0
Hi mrmmickle1!! :)
I was able to figure out the code, thank u so much for all your help. I ended up using the offset function and it did the job!

I do have another question tho; is there a way to make the selection in the offset function dynamic? Ie if in my macro I'm selecting all cells with a specific number in them, then I want to 'offset' the selection (select the cells 2 rows directly below the current selection. But the number of cells selected in the first step vary. How would the code change for this?

Thank you and have a lovely week! :)
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top