ajdinspector
New Member
- Joined
- Nov 5, 2018
- Messages
- 8
Hi! So i have a data set that is exported by a database, so can't change it's format. I have a script to copy and paste it into my sheet and it works fine:
One of my formulas doesn't recognize the data as a date, so i want to "Match Destination Formatting (M)" just like a right-click special paste. so this is what i tried:
and i get the error "Compile error: Named argument not found"
What am i doing wrong here? Thanks in advance! Also, this is only my second post so if i need to show more or less of my code, or something else to improve future postings please let me know. Thanks!
Code:
'set the range reference variables
Set Bk = Sheet3.Range("C5") 'file path of book to import from
Set Sh = Sheet3.Range("F5") 'sheet to import
Set St = Sheet3.Range("G5") 'starting cell reference
Set Fn = Sheet3.Range("H5") 'finishing cell reference
Set Tb = Sheet3.Range("I5") 'sheet in this workbook to send it to
'set the destination
Set addme = Worksheets(Tb.Value).Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
'open the workbook
Set wb = Workbooks.Open(Bk)
'set the copy range
Set CopyData = Worksheets(Sh.Value).Range(St & ":" & Fn)
'copy and paste the data
CopyData.Copy
addme.PasteSpecial xlPasteValues
Code:
'copy and paste the data
CopyData.Copy
addme.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
What am i doing wrong here? Thanks in advance! Also, this is only my second post so if i need to show more or less of my code, or something else to improve future postings please let me know. Thanks!
Last edited: