Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Effecient method of copying and pasting required

Hi all,
I'm automating the copying of some numbers from one worksheet to
another. The values being copied have formulae behind them but I only
want the value hence the use of PasteSpecial in the below code. Below
code works for capturing one value but I need to capture several and
am sure there are more effecient ways then simply going back and forth
between the worksheets. I've tried to assign the values to "Long" or
"Double" but seem to capture the numbers in decimal format. Please
help I've no idea what else to do.


Thank you kindly
Khurram


Workbooks.Open Filename:="C:\Feb Batch Metrics.xls"

Workbooks("Feb Batch Metrics.xls").Sheets("Batch
Metrics").Range("I47").Select
ActiveCell.Copy
Windows(2).Activate
Sheets("SD Summary").Select
Cells(1, 1).Select
Selection.PasteSpecial xlPasteValues

Windows(2).Activate
Workbooks("Feb Batch Metrics.xls").Sheets("Batch
Metrics").Range("F47").Select
ActiveCell.Copy
Windows(2).Activate
Sheets("SD Summary").Select
Cells(2, 1).Select
Selection.PasteSpecial xlPasteValues

Workbooks("Feb Batch Metrics.xls").Close SaveChanges:=False

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Effecient method of copying and pasting required

Khurram,
It's not clear which workbook is referenced by Windows(2).Activate, but you
can amend the code below to suit:

Private Sub CommandButton1_Click()
Dim SourceWB As Workbook
Dim DestinationWS As Worksheet

Set DestinationWS = ThisWorkbook.Sheets("SD Summary")
Set SourceWB = Workbooks.Open(Filename:="C:\Feb Batch Metrics.xls")

With SourceWB.Sheets("Batch Metrics")
DestinationWS.Range("A1").Value = .Range("I47").Text
DestinationWS.Range("A2").Value = .Range("F47").Text
End With

End Sub

NickHK

"Khurram" wrote in message
oups.com...
Hi all,
I'm automating the copying of some numbers from one worksheet to
another. The values being copied have formulae behind them but I only
want the value hence the use of PasteSpecial in the below code. Below
code works for capturing one value but I need to capture several and
am sure there are more effecient ways then simply going back and forth
between the worksheets. I've tried to assign the values to "Long" or
"Double" but seem to capture the numbers in decimal format. Please
help I've no idea what else to do.


Thank you kindly
Khurram


Workbooks.Open Filename:="C:\Feb Batch Metrics.xls"

Workbooks("Feb Batch Metrics.xls").Sheets("Batch
Metrics").Range("I47").Select
ActiveCell.Copy
Windows(2).Activate
Sheets("SD Summary").Select
Cells(1, 1).Select
Selection.PasteSpecial xlPasteValues

Windows(2).Activate
Workbooks("Feb Batch Metrics.xls").Sheets("Batch
Metrics").Range("F47").Select
ActiveCell.Copy
Windows(2).Activate
Sheets("SD Summary").Select
Cells(2, 1).Select
Selection.PasteSpecial xlPasteValues

Workbooks("Feb Batch Metrics.xls").Close SaveChanges:=False



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Effecient method of copying and pasting required

This code is better for going back and forth between sheets

Cancel = True

Workbooks.Open Filename:="C:\Feb Batch Metrics.xls"

Workbooks("Feb Batch Metrics.xls"). _
Worksheets("Batch Metrics"). _
Range("I47").Copy
Workbooks("Feb Batch Metrics.xls"). _
Worksheets("SD Summary").Range("A1").PasteSpecial xlPasteValues

Workbooks("Feb Batch Metrics.xls"). _
Worksheets("Batch Metrics"). _
Range("F47").Copy
Workbooks("Feb Batch Metrics.xls"). _
Worksheets("SD Summary").Range("A2").PasteSpecial xlPasteValues


Workbooks("Feb Batch Metrics.xls").Close SaveChanges:=False

"Khurram" wrote:

Hi all,
I'm automating the copying of some numbers from one worksheet to
another. The values being copied have formulae behind them but I only
want the value hence the use of PasteSpecial in the below code. Below
code works for capturing one value but I need to capture several and
am sure there are more effecient ways then simply going back and forth
between the worksheets. I've tried to assign the values to "Long" or
"Double" but seem to capture the numbers in decimal format. Please
help I've no idea what else to do.


Thank you kindly
Khurram


Workbooks.Open Filename:="C:\Feb Batch Metrics.xls"

Workbooks("Feb Batch Metrics.xls").Sheets("Batch
Metrics").Range("I47").Select
ActiveCell.Copy
Windows(2).Activate
Sheets("SD Summary").Select
Cells(1, 1).Select
Selection.PasteSpecial xlPasteValues

Windows(2).Activate
Workbooks("Feb Batch Metrics.xls").Sheets("Batch
Metrics").Range("F47").Select
ActiveCell.Copy
Windows(2).Activate
Sheets("SD Summary").Select
Cells(2, 1).Select
Selection.PasteSpecial xlPasteValues

Workbooks("Feb Batch Metrics.xls").Close SaveChanges:=False


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
help making code more effecient timmulla Excel Programming 2 January 23rd 07 05:20 AM
Summary sheet in effecient way sumit Excel Discussion (Misc queries) 0 December 11th 06 10:00 AM
MATCH AMOUNT FIFO METHOD & INSERT ROWS WHERE EVER REQUIRED. Eddy Stan Excel Programming 7 March 29th 06 05:38 AM
Effecient use of Arrays for encryption? jasonsweeney[_95_] Excel Programming 1 October 29th 05 02:36 PM
Effecient way to check, add, delete duplicates vbastarter Excel Programming 3 August 17th 04 05:28 PM


All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"