Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default help with code to paste from another workbook

i have a summary workbook and for some reason i can't get it to paste the
values from the source workbook. i open the workbook, it seems to go through
all of the cells, but it never matches my criteria and pastes the value. can
some see what is worng?


With Workbooks(Fname).Worksheets(sh) ' this is the source
For sh = 1 To 2 ' only 2 sheets to test with
Set rng = .Range("B3:B33") ' range to look for the value in the if statement
For Each cell In rng
If UCase(cell.Value) = "S" Then
.cell.Offset(0, 1).Copy ' if true, copy the number in column C and
paste it to F4 in the summary workbook
Workbooks(Curbook).Worksheets(Cursheet).Range("f4" ).PasteSpecial _
xlValues, operation:=xlAdd
End If
Next cell
Next sh
End With

--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default help with code to paste from another workbook

DIM WS as Worksheet
SET WS = Workbooks(Curbook).Worksheets(Cursheet)
With Workbooks(Fname).Worksheets(sh) ' this is the source
For sh = 1 To 2 ' only 2 sheets to test with
Set rng = .Range("B3:B33") ' range to look for the value in the if statement
For Each cell In rng.Cells
If UCase(cell.Value) = "S" Then
WS.Range("f4").Value = WS.Range("f4").Value + .cell.Offset(0,
1).Value
End If
Next cell
Next sh
End With



"Gary Keramidas" wrote:

i have a summary workbook and for some reason i can't get it to paste the
values from the source workbook. i open the workbook, it seems to go through
all of the cells, but it never matches my criteria and pastes the value. can
some see what is worng?


With Workbooks(Fname).Worksheets(sh) ' this is the source
For sh = 1 To 2 ' only 2 sheets to test with
Set rng = .Range("B3:B33") ' range to look for the value in the if statement
For Each cell In rng
If UCase(cell.Value) = "S" Then
.cell.Offset(0, 1).Copy ' if true, copy the number in column C and
paste it to F4 in the summary workbook
Workbooks(Curbook).Worksheets(Cursheet).Range("f4" ).PasteSpecial _
xlValues, operation:=xlAdd
End If
Next cell
Next sh
End With

--


Gary




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default help with code to paste from another workbook

thanks patrick, i was able to get it working with your help. i think all i
had to do was remove the period before the word range (Set rng =
Range("B3:B33")), which i had in my original post.

thanks again

--


Gary


"Patrick Molloy" wrote in message
...
DIM WS as Worksheet
SET WS = Workbooks(Curbook).Worksheets(Cursheet)
With Workbooks(Fname).Worksheets(sh) ' this is the source
For sh = 1 To 2 ' only 2 sheets to test with
Set rng = .Range("B3:B33") ' range to look for the value in the if
statement
For Each cell In rng.Cells
If UCase(cell.Value) = "S" Then
WS.Range("f4").Value = WS.Range("f4").Value + .cell.Offset(0,
1).Value
End If
Next cell
Next sh
End With



"Gary Keramidas" wrote:

i have a summary workbook and for some reason i can't get it to paste the
values from the source workbook. i open the workbook, it seems to go
through
all of the cells, but it never matches my criteria and pastes the value.
can
some see what is worng?


With Workbooks(Fname).Worksheets(sh) ' this is the source
For sh = 1 To 2 ' only 2 sheets to test with
Set rng = .Range("B3:B33") ' range to look for the value in the if
statement
For Each cell In rng
If UCase(cell.Value) = "S" Then
.cell.Offset(0, 1).Copy ' if true, copy the number in column C
and
paste it to F4 in the summary workbook
Workbooks(Curbook).Worksheets(Cursheet).Range("f4" ).PasteSpecial
_
xlValues, operation:=xlAdd
End If
Next cell
Next sh
End With

--


Gary






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
copy and paste using code from workbook to workbook bigdaddy3 Excel Discussion (Misc queries) 2 September 14th 05 11:06 AM
Selecting data from 1 workbook to copy and paste to a 2nd workbook JackSpam Excel Programming 2 July 20th 05 02:33 AM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM
VBA code gets lost from workbook if I paste in new data and save??? Lonnie[_3_] Excel Programming 1 April 8th 04 05:49 PM


All times are GMT +1. The time now is 05:48 PM.

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"