Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copy and paste using code from workbook to workbook | Excel Discussion (Misc queries) | |||
Selecting data from 1 workbook to copy and paste to a 2nd workbook | Excel Programming | |||
I cannot paste from one workbook to another. Copy works, paste do. | Excel Discussion (Misc queries) | |||
Copy a range of cells in an unopened workbook and paste it to the current workbook | Excel Programming | |||
VBA code gets lost from workbook if I paste in new data and save??? | Excel Programming |