VBA Command Button to send only certain data to new Workbook

Danin

New Member
Joined
Sep 16, 2016
Messages
6
I have an excel worksheet set up as a form in a workbook. from that form i upload to a workbook on our main server parts of it that I need to log.
I want to edit this form and change what it uploads.
CosCodeDescriptionStartdateEndDateRateUoMTotal
TestCodeGenerator 1 of 201/06/20704/06/2017$1.00day$4.00
TestCode1Generator 2 of 203/06/2017004/06/2017$1.00day$2.00

<tbody>
</tbody>

I want to enter above underlined to cells into new workbook. But if the rows are empty i want it not enter empty rows. there are 7 rows to enter details into on the form.
I have vba set up to enter cells for the purchase number date supplier etc. it is getting the vba to stop if the cells are empty. how can I write that part and where should I put it?

Private Sub CommandButton1_Click()
Dim Area As String
Dim Supplier As String, PurchaseNumber As Long
Dim Description As String, Commercial As String
Dim Approved As String, Costcode As String
Dim PODate As Long
Dim Total_GSTexc As Single
Dim PurchaseOrder As Workbook
Worksheets("PurchaseOrder").Select
Area = Range("G6")
Worksheets("PurchaseOrder").Select
PurchaseNumber = Range("H6")
Worksheets("PurchaseOrder").Select
PODate = Range("H7")
Worksheets("PurchaseOrder").Select
Supplier = Range("B6")
Worksheets("PurchaseOrder").Select
Description = Range("A35")
Worksheets("PurchaseOrder").Select
Costcode = Range("D35")
Worksheets("PurchaseOrder").Select
Commercial = Range("A32")
Worksheets("PurchaseOrder").Select
Approved = Range("A29")
Worksheets("PurchaseOrder").Select
Total_GSTexc = Range("H26")
Set PurchaseOrder = Workbooks.Open("P:\put address here example.xlsb")
Worksheets("NewPurchaseOrders").Select
Worksheets("NewPurchaseOrders").Range("A3").Select
RowCount = Worksheets("NewPurchaseOrders").Range("A1").CurrentRegion.Rows.Count
With Worksheets("NewPurchaseOrders").Range("A1")
.Offset(RowCount, 0) = Area
.Offset(RowCount, 1) = PurchaseNumber
.Offset(RowCount, 2) = PODate
.Offset(RowCount, 3) = Supplier
.Offset(RowCount, 4) = Description
.Offset(RowCount, 5) = Costcode
.Offset(RowCount, 6) = Approved
.Offset(RowCount, 7) = Commercial
.Offset(RowCount, 8) = Total_GSTexc
End With
PurchaseOrder.Save


End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
To add to this question as below is what I am trying to move. sometimes it will only have one row of information other times it could have 5 lines. How do I tell it only to enter rows that have information in it otherwise skip to next row? I only want to send the Blue columns.
CostCodeDescriptionOn Hire DateOff Hire Date UnitRateAmount (ex. GST)
testcode1 of 4 VMS Boards1/06/201710/06/20179 day $30.00 $ 270.00
testcode2 of 4 VMS Boards2/06/201715/06/201713 day $30.00 $ 390.00
testcode3 of 4 VMS Boards4/06/201710/06/20176 day $30.00 $ 180.00
0 $ -
$ -
$ -

<colgroup><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,136
Messages
6,129,080
Members
449,485
Latest member
greggy

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