Sending Complete Row Values to a Closed Workbook

TBrecht

New Member
Joined
Oct 5, 2020
Messages
6
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hello,

I am fairly new to VBA and cannot find anything online that will fix my issue. In a quick description of my process. I have dropdowns lists throughout my template master that feed the values to Row 2 of sheet "Summary". I then have a button that I want click to send that entire row values to a closed workbook.

My current Code (found on youtube) is below minus my saving location. The problem I am running into is when the row pastes into the closed sheet it pastes the formula and not the value. I have tried entering .PasteSPecial and didn't have any luck. I don't know if i am entering it incorrect maybe? Any help would be appreciated! Or if you have another idea that may work better. I will be using DropBox if that makes a difference. Thanks for the help!

VBA Code:
Private Sub CommandButton1_Click()
Dim WB As Workbook
ThisWorkbook.Worksheets("Summary").Rows(2).Select
Selection.Copy

Set WB = Workbooks.Open("C:\SAVINGLOCATIONy.xlsx")
WB.Worksheets("Tank Query").Activate

LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

ActiveSheet.Cells(LastRow + 1, 1).Select

Worksheets("Tank Query").Paste

ActiveWorkbook.Save

ActiveWorkbook.Close savechanges = Ture

Set WB = Nothing

ThisWorkbook.Worksheets("summary").Activate
ThisWorkbook.Worksheets("Summary").Cells(1, 1).Select

Application.CutCopyMode = False

End Sub
 
Last edited by a moderator:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub CommandButton1_Click()
   Dim WB As Workbook
   
   ThisWorkbook.Worksheets("Summary").Rows(2).Select
   Set WB = Workbooks.Open("C:\SAVINGLOCATIONy.xlsx")
   With WB.Worksheets("Tank Query")
      ThisWorkbook.Worksheets("Summary").Rows(2).Copy
      .Range("A" & .Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
   End With
   Application.CutCopyMode = False
   WB.Close True
   Set WB = Nothing
End Sub
 
Upvote 0
Solution
Thanks! That worked but I forgot to mention I have the "Tank Query" file as a Read Only. Everything uploads now but it wants me to save as vs save over. Is there a fix for this? If not its no big.
 
Upvote 0
You cannot save a read only file.
You will either need to allow read/write access, or save as.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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