Excel/Copying data from filtered range in a different workbook
Hello Tom -
Using Excel 2010, I have two workbooks (master and department) which contain the same columns of data. There are 3 "block" of columns - one each for beginning of year, mid-year and end of year. The department workbook contains all of the same records as the master workbook; however, each department can update only their records within the department workbook. I am writing a procedure to do the following:
1. Open each department workbook
2. Filter on the department to isolate their records
3. Loop through the department's records to determine whether a change was made and, if so, to which "block"
4. If a change was made, copy the correct "block" from the department's record and paste on the corresponding block and record in the master workbook.
Is there an easy way to take a record from the department workbook, store it in a range variable and then copy portions of the range variable into the master workbook?
You can use a variant variable that holds an array.
Dim v As Variant
v = ActiveSheet.Range("B9:S50").Value
MsgBox "Value from Row 15, column M: " & v(7, 12)
v(1,1) will be the value from B9. The arguments are v(row, column). Now row is not a row in the worksheet - it is a row in the two dimensional array "v". The first row in v has data from row 9 in the sheet because that is where we started when we assigned values to it.
Does that answer the question?
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here