vba - Best Way to Create Import Files with Excel? -


not sure best way describe situation is, i'll best. trying create import file database system using excel.

here have example:

1) names in column 2) accounts in column (accounts 1-3) 3) amounts (an amount each combo, ex: name1, account1, name 1, account2) 

so want easy way (possibly vba?) create import file similar below:

(columns a, b, c) name#1, account#1, amount#1 name#1, account#2, amount#2 name#1, account#3, amount#3 name#2, account#1, amount#4 name#2, account#2, amount#5 etc.. etc.. 

is there anyway without having ton of copying , pasting? tried pivot tables, doesn't seem work situation

sample data:

names     |  accounts   |   amounts david        11230          $32.50 marry        11240          $2.00 jerry        54500          $990.00              64000          $500.00                             $300.00                             $600.00                             $330.55                             $500.00                             $45.00                             $53.38                             $75.00                             $44.00 

thus intended output want is:

david, 11230, $32.50 david, 11240, $2.00 david, 54500, $990.00 david, 64000, $500.00 marry, 11230, $300.00 marry, 11240, $600.00 ....continue... 

hope helps

this worked me:

sub tester()      dim sht worksheet, rngnames range, rngaccts range     dim nm range, acct range, long      set sht = activesheet      sht         set rngnames = .range(.range("a2"), _                           .cells(.rows.count, 1).end(xlup))         set rngaccts = .range(.range("b2"), _                           .cells(.rows.count, 2).end(xlup))     end      = 1      each nm in rngnames.cells     each acct in rngaccts.cells         = + 1         sht.cells(i, 5).value = nm.value         sht.cells(i, 6).value = acct.value         sht.cells(i, 7).value = sht.range("c1").offset(i - 1, 0).value     next acct     next nm  end sub 

inputs in cola-c, output goes cols e-g


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -