Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Should be easy...what's missing?

Code doesn't work due to error on line: c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Select
Application.CutCopyMode = False
Selection.Copy
c.Address.Select
ActiveCell.Offset(0, -6).Range("A1").Select
ActiveSheet.Paste
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into columns
A through F (in the same row as the cell that was just found in .Find)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Should be easy...what's missing?

Address is a String value... you can't select a String. Try just c.Select
and see if that works for you.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Code doesn't work due to error on line: c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Select
Application.CutCopyMode = False
Selection.Copy
c.Address.Select
ActiveCell.Offset(0, -6).Range("A1").Select
ActiveSheet.Paste
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into
columns
A through F (in the same row as the cell that was just found in .Find)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Should be easy...what's missing?

You actually don't need to select a cell to copy/paste - you can just
refference them.
Also c.address retruns a string and not the cell (range) object itself
- and you can't select a string (you can select a range).
Also be careful when using ActiveSheet - be sure you really want to
paste into the ACTIVE sheet and not a specific one - e.g., the code
below would paste into Sheet3 as oppose to ActiveSheet that you had.
Amend as necessary.

Try this:

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Copy destination:=
Worksheets("Sheet3").cells(c.row, "A")
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


On Mar 29, 2:47*pm, MovingBeyondtheRecordButton
.com wrote:
Code doesn't work due to error on line: *c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
* * Set c = .Find(F.Value, LookIn:=xlValues)
* * If Not c Is Nothing Then
* * * * firstAddress = c.Address
* * * * Do
* * * * * * Worksheets("Sheet3").Range("Q2:V2").Select
* * * * * * Application.CutCopyMode = False
* * * * * * Selection.Copy
* * * * * * c.Address.Select
* * * * * * ActiveCell.Offset(0, -6).Range("A1").Select
* * * * * * ActiveSheet.Paste
* * * * * * Set c = .FindNext(c)
* * * * Loop While Not c Is Nothing And c.Address < firstAddress
* * End If
* * End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into columns
A through F (in the same row as the cell that was just found in .Find)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Should be easy...what's missing?

hi
c.address is not a selectable object. address is a string.
try
c.select or
range(c.address).select

also...seldom do you have to accually select. you can usually just reference
the ranges.
Worksheets("Sheet1").Range("Q2:V2").copy Destination:= _
c.Offset(0, -6).Range("A1")

Regards
FSt1

"MovingBeyondtheRecordButton" wrote:

Code doesn't work due to error on line: c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Select
Application.CutCopyMode = False
Selection.Copy
c.Address.Select
ActiveCell.Offset(0, -6).Range("A1").Select
ActiveSheet.Paste
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into columns
A through F (in the same row as the cell that was just found in .Find)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Should be easy...what's missing?

Using c.Select resulted in a run-time error '1004 Select method of range
class failed

"Rick Rothstein" wrote:

Address is a String value... you can't select a String. Try just c.Select
and see if that works for you.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Code doesn't work due to error on line: c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Select
Application.CutCopyMode = False
Selection.Copy
c.Address.Select
ActiveCell.Offset(0, -6).Range("A1").Select
ActiveSheet.Paste
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into
columns
A through F (in the same row as the cell that was just found in .Find)

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Should be easy...what's missing?

Okay, I looked at your code a little more closely... the problem you are
having is because you are trying to select cells from a non-active
worksheet... you can't do that... and you don't have to. Look at AB's and
FSt1's responses to see how not to rely on selecting cells before you
perform operations with them.

Perhaps this previous posting of mine (a response to another person using
Select/Selection type constructions) will be of some help to you also...

Whenever you see code constructed like this...

Range("A1").Select
Selection.<whatever

you can almost always do this instead...

Range("A1").<whatever

In your particular case, you have this...

Range("C2:C8193").Select 'select cells to export
For Each r In Selection.Rows

which, using the above concept, can be reduced to this...

For Each r In Range("C2:C8193").Rows

Notice, all I have done is replace Selection with the range you Select(ed)
in the previous statement and eliminate the process of doing any
Select(ion)s. Stated another way, the Selection produced from
Range(...).Select is a range and, of course, Range(...) is a range... and,
in fact, they are the same range, so it doesn't matter which one you use.
The added benefit of not selecting ranges first is your active cell does not
change.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Using c.Select resulted in a run-time error '1004 Select method of range
class failed

"Rick Rothstein" wrote:

Address is a String value... you can't select a String. Try just c.Select
and see if that works for you.

--
Rick (MVP - Excel)



"MovingBeyondtheRecordButton"
.com wrote in message
...
Code doesn't work due to error on line: c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Select
Application.CutCopyMode = False
Selection.Copy
c.Address.Select
ActiveCell.Offset(0, -6).Range("A1").Select
ActiveSheet.Paste
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into
columns
A through F (in the same row as the cell that was just found in .Find)

.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Should be easy...what's missing?

The copied cells contain formulas and I need to copy values only otherwise it
changes all the rows of data to equal the last row of data.

I tried...
Worksheets("Sheet3").Range("Q2:V2").Values.Copy
Destination:=Worksheets("Sheet2").Cells(c.Row, "A")

But...it doesn't like where I put the word Values

"AB" wrote:

You actually don't need to select a cell to copy/paste - you can just
refference them.
Also c.address retruns a string and not the cell (range) object itself
- and you can't select a string (you can select a range).
Also be careful when using ActiveSheet - be sure you really want to
paste into the ACTIVE sheet and not a specific one - e.g., the code
below would paste into Sheet3 as oppose to ActiveSheet that you had.
Amend as necessary.

Try this:

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Copy destination:=
Worksheets("Sheet3").cells(c.row, "A")
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


On Mar 29, 2:47 pm, MovingBeyondtheRecordButton
.com wrote:
Code doesn't work due to error on line: c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Select
Application.CutCopyMode = False
Selection.Copy
c.Address.Select
ActiveCell.Offset(0, -6).Range("A1").Select
ActiveSheet.Paste
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into columns
A through F (in the same row as the cell that was just found in .Find)


.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Should be easy...what's missing?

The "copy Destination:=" sounds like it would work but how do I tell it to
copy Destination Values only?

"FSt1" wrote:

hi
c.address is not a selectable object. address is a string.
try
c.select or
range(c.address).select

also...seldom do you have to accually select. you can usually just reference
the ranges.
Worksheets("Sheet1").Range("Q2:V2").copy Destination:= _
c.Offset(0, -6).Range("A1")

Regards
FSt1

"MovingBeyondtheRecordButton" wrote:

Code doesn't work due to error on line: c.Address.Select

With Worksheets("Sheet2").Range("G2:G76")
Set c = .Find(F.Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Worksheets("Sheet3").Range("Q2:V2").Select
Application.CutCopyMode = False
Selection.Copy
c.Address.Select
ActiveCell.Offset(0, -6).Range("A1").Select
ActiveSheet.Paste
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

I want to..

1) find where F.Value = the Value of a cell in
Worksheets("Sheet2").Range("G2:G76")
2) paste values from cells Worksheets("Sheet3").Range("Q2:V2") into columns
A through F (in the same row as the cell that was just found in .Find)

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Should be easy...what's missing?

Just split it up into 2 lines (and don't use the 'destination'):

Worksheets("Sheet3").Range("Q2:V2").Copy

Worksheets("Sheet2").Cells(c.Row, "A") .PasteSpecial xlPasteValues


On Mar 29, 4:16*pm, MovingBeyondtheRecordButton
.com wrote:
The "copy Destination:=" sounds like it would work but how do I tell it to
copy Destination Values only?

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
Type.Missing vs. System.Reflection.Missing.Value as WSF parameters? Fabz[_2_] Excel Programming 1 March 8th 10 09:52 AM
Am I missing some easy solution to my problem? JJ Excel Worksheet Functions 2 September 17th 09 10:42 AM
Toolbars Missing, And option to Add Missing SmeetaG Excel Discussion (Misc queries) 3 October 19th 05 11:43 AM
On Error? Creates 1 missing worksheet then never detects any other missing worksheets Craigm[_35_] Excel Programming 2 August 1st 05 02:39 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM


All times are GMT +1. The time now is 01:39 AM.

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"