Transfering Data

dramey1

New Member
Joined
Jun 21, 2017
Messages
22
I am trying to set up a button to press have a specific range be copied out of my current workbook and placed into another workbook not open in my computer. The problem I'm having is every time I press the button, the information replaces my last entry. In need to be able to copy it into the other file and have it keep a list. Here's my code:
Private Sub CommandButton1_Click()


Dim wkb1 As Workbook
Dim sht1 As Worksheet
Dim wkb2 As Workbook
Dim sht2 As Worksheet


Application.ScreenUpdating = False


Set wkb1 = ThisWorkbook
Set wkb2 = Workbooks.Open("Scope.xlsx")
lastrow = Workbooks("Scope.xlsx").Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set sht1 = wkb1.Sheets("ASCE")
Set sht2 = wkb2.Sheets("Sheet1")


sht1.Range("L3").Copy
sht2.Range("A" & lastrow).PasteSpecial xlPasteValues
Application.CutCopyMode = False
wkb2.Close True


Application.ScreenUpdating = True


End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Code:
Dim wkb1 As Workbook
Dim sht1 As Worksheet
Dim wkb2 As Workbook
Dim sht2 As Worksheet


Application.ScreenUpdating = False


Set wkb1 = ThisWorkbook
Set wkb2 = Workbooks.Open("Scope.xlsx")
lastrow = Workbooks("Scope.xlsx").Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set sht1 = wkb1.Sheets("ASCE")
Set sht2 = wkb2.Sheets("Sheet1")


sht1.Range("L3").Copy
sht2.Range("A" & lastrow + 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
wkb2.Close True


Application.ScreenUpdating = True


End Sub
 
Upvote 0
Thank you. One more question. I have a table with 7 different columns. Each assembly has a possible 7 different combinations. How can I count how many times each combination is used without typing out every combination separately?
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top