ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Method 'Range" of object'_Global' failed (https://www.excelbanter.com/excel-programming/292308-method-range-object_global-failed.html)

tim

Method 'Range" of object'_Global' failed
 

I get this error when i try to run, how could i place variables in the selection


Sheets("Eclipse").Selec
Range("A1").Selec
Cells.Find(What:="wopr", After:=ActiveCell, LookIn:=xlFormulas, LookAt
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=
False).Activat
Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
.Activat
x = Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
.Activat
y = Selection.End(xlDown).Selec
Range("A$x:A$y").Select <-----------------------------------------------------------------Problem lin
Application.CutCopyMode = Fals
Selection.Cop
Sheets("Sheet1").Selec
Range("D2").Selec
ActiveSheet.Past

End Sub

Tom Ogilvy

Method 'Range" of object'_Global' failed
 
Range("A" & x & ":A" & y).Select

--
Regards,
Tom Ogilvy

"Tim" wrote in message
...

I get this error when i try to run, how could i place variables in the

selection.



Sheets("Eclipse").Select
Range("A1").Select
Cells.Find(What:="wopr", After:=ActiveCell, LookIn:=xlFormulas, LookAt

_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,

MatchCase:= _
False).Activate
Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas,

LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,

MatchCase:=False) _
.Activate
x = Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas,

LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,

MatchCase:=False) _
.Activate
y = Selection.End(xlDown).Select
Range("A$x:A$y").Select

<-----------------------------------------------------------------Problem
line
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("D2").Select
ActiveSheet.Paste

End Sub




Medemper

Method 'Range" of object'_Global' failed
 
Not sure if you wanted to search for the 2nd "7p2" after wopr or not.

Sub FindAndCopy()
Sheets("Eclipse").Select
Range("A1").Select
Cells.Find(What:="wopr", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
.Activate
Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
.Select
x = ActiveCell.Address
Selection.End(xlDown).Select
y = ActiveCell.Address
Range(x, y).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("D2").Select
ActiveSheet.Paste

End Sub
"Tim" wrote in message ...

I get this error when i try to run, how could i place variables in the selection.



Sheets("Eclipse").Select
Range("A1").Select
Cells.Find(What:="wopr", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
.Activate
x = Cells.Find(What:="7p2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
.Activate
y = Selection.End(xlDown).Select
Range("A$x:A$y").Select <-----------------------------------------------------------------Problem line
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("D2").Select
ActiveSheet.Paste

End Sub


All times are GMT +1. The time now is 04:22 PM.

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