Bob, I deleted my section of code and replaced it with yours. I still got an
error. To be honest, it took me a half hour to get the correct syntax. There
was an extra "." in the code. I've never coded with Visual Basic before so
you can tell I have no idea how to fix the rest of my code. I don't mind
learning new things, but for what I'm trying to accomplish it may take me 10
hours to figure this out. If you could adjust my code here I would greatly
appreciate it. Here's the whole macro. I added comments with the ' sign.
Thanks Bob.
Sub CreateData()
Range("A1").Select
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("M39").Select
' This range needs to be offset (0,11)
ActiveCell.FormulaR1C1 = "=(RC[-11]*R10C2)-R10C2"
Range("M39").Select
' Range needs to be offset (0,11)
Selection.AutoFill Destination:=Range("M39:M201"), Type:=xlFillDefault
' M39:M201 needs to be offset. (M39 would be 11 boxes to the
' right. M201 would 11 boxes to the right and 200 down)
Range("M39:M201").Select
' offset again
Range("A1").Select
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("C39:C201").Select
' Don't need offset
Selection.Copy
Range("A1").Select
ActiveWindow.SmallScroll Down:=24
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("N39").Select
' offset (0,12)
ActiveSheet.Paste
Range("A1").Select
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("M100:M208").Select
' I have no idea how this would work. My data has 2 trials in column A
' The problem is I need to seperate them to get two seperate graphs
' In column A, my data is 1,1,1,1....etc. then trial 2 starts
' 2,2,2,2,2,2...etc. How would you offset it so that the first number 2 is
' selected everytime. Then from there offset (0,12)
Application.CutCopyMode = False
Selection.Copy
Range("A1").Select
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("L39").Select
' offset (0,9)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("C100:C208").Select
' again offset with the first number 2
Application.CutCopyMode = False
Selection.Copy
Range("A1").Select
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("O39").Select
' offset (0,13)
ActiveSheet.Paste
Range("A1").Select
Cells.Find(What:="dev", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("L100:O208").Select
' offset with first 2
Application.CutCopyMode = False
Selection.ClearContents
Range("A1").Select
End Sub
Bob Phillips said:
Getting the last row is quite simple as long as you know where you judge it
against. So for instance if column A holds the id, check it back against
there.
The code I gave creates a range object oCell where the found data resides.
You just offset against this.
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
I think it would be a lot harder if I had to determine the last row, so
what
I do is just go down 200 or so cells after my starting point. The graph
doesn't include empty cells so I'm okay. I just see a lot of problems with
this because I'm using a lot of offsetting. I'll test that code tomorrow
at
work but I have a question though. My macro includes a lot of steps and
offsetting. Should I go by your code to complete the rest of my macro, or
are
there are special steps for me to to do to complete the rest of my macro
with
an offset?
:
That will teach me to test it.
Amended code below, but how do you determine where the last row is,