- Nov 6, 2015
I'm not very experienced with making custom functions. I have the following code to copy tables without the use of the clipboard. I have a large project with many copy & paste events that I would like to replace with this code to speed up my program. It would be must faster if I had a customer function I could call instead of repeating the same code throughout my project. The only thing that would change would be the worksheet name, the table name, and the destination cell/worksheet. My question would be, how do I turn this code into a custom function?
Rich (BB code):
Dim SourceRng as range Dim DestinationRng as range 'Table you want to copy Set SourceRng = cWS.ListObjects("CallVolume").DataBodyRange 'Only need to specify the top/left destination cell, then resize range to match SourceRng Set DestinationRng = bWS.Range("A" & (LR + 1)).Resize(SourceRng.Rows.Count, SourceRng.Columns.Count) 'Then copy the values from source to destination DestinationRng.Value = SourceRng.Value