dpiano1984
New Member
- Joined
- Feb 8, 2013
- Messages
- 14
Hello all,First of all this is my first post. I'm new to VBA, but I'm intermediate with excel and recently found the wonderful world of VisualBasic. Here's what I'm trying to doThere is a spreadsheet that I work on everyday where I pull data from another spreadsheet (this is a different spreadsheet everyday, but the task is repeated the same). I copy cells in E#:O# and paste them into D#:N#. I figured you could automate this by writing a code to perform a vlookup for each cell. The code I have so far is this: '''''''''''''''''''''''''''''' 'Message Box for File Browsing '''''''''''''''''''''''''''''' Dim myfile As String MsgBox ("Please Browse for the File That You Would like to Reference") myfile = Application.GetOpenFilename Range("D2").FormulaR1C1 = "=vlookup(rc1,][myfile]ACCRUAL BALANCE TOTALS'!C3:C5,3,FALSE)"-------------------the last line is repeated up until Range("N2") and I then have this code written for the rest:Range("D2:N2").Copy Destination:=Range("D3:N201") MsgBox ("Autofill of Worksheet Complete")-------------The main problem I keep having is the first line of my spreadsheet will return "N/A" and the rest will be perfect. The other problem is if there is an error in the first few lines it re-formats my sheet so that the columns are numerical instead of alphabetical. Is there an easier code I can write or do I need more parameters for VBA to abide by?