Bobbyleeds

New Member
Joined
Oct 27, 2015
Messages
3
Hi Guys,
First time poster here.
I have an excel workbook that i am using as a form and have VBA to transfer data from that form to to a database workbook.
See code below
Public Sub copy_wb()

Dim copy_from As Range
Dim copy_to As Range

Set copy_from = Workbooks("Ideas Form_0 2").Worksheets(2).Range("B10:Y10")
Set copy_to = Workbooks("New Ideas Database").Worksheets(1).Range("B" & Rows.Count).End(xlUp).Offset(1, 0)

copy_from.Copy Destination:=copy_to
Application.CutCopyMode = False

MsgBox ("Data added successfully!")

End Sub
The way to form works is by the user opening the excel from Sharepoint filling out the relevant info and then i have VBA to email a copy of this to a specific email address and to clear the form after this and they then close excel.

This works fine, the problem comes when trying to use the VBA above to transfer data to the database from the attached email copy as the file name gets given a version number when it is opened from the email, so 'Ideas Form_0 2' becomes 'Ideas Form_0 2 (004)' and therefore i think this makes the VBA not work properly.

Is there anything i can change in the code so that VBA doesn't take into account the version number (the number in brackets) when running the VBA so that it will always work (and transfer the data to the database) no matter how many copies are emailed to the email address?

Thanks in advance.

Robert
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Or is there and code that will transfer data from any workbook without needing a filename as I can just set it up to transfer data from the specific cells?
 
Upvote 0
or is there any code to attach and send a current active workbook via email but change the filename of the workbook before it is attached?
 
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,693
Members
449,179
Latest member
kfhw720

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