Excel VBA to search for specific text in cell and then copy to another sheet -


i want make macro copy date cell j5, copy invoice no. cell h6, copy consumer name merged cells a6 , copy amount of items under product description cell range (b11:b21) items in invoice sheet , paste values sheet name invoice-record there table headers consumer name, date, invoice no. items

(sub headers of item1, item2, item3, item4, item6, item7, item8, item9, item10, item11, item12)

i want macro copy these values invoice sheet , paste under headers of each in table in invoice-record sheet. elaborate better, giving link of workbook:

https://www.dropbox.com/s/6wu69cgn3qfvr67/invoice.xlsx?dl=0 

start moving data know moves setting values in beginning.
tricky part checking each item.

since know there 12 of them, long example provided how it's going laid out, loop through count of 12 , each one, compare items in invoice product number, if it's on invoice, set in appropriate column on target sheet.

tested: using example sheet, see screenshots.

sub invoicerecord()  dim source string dim target string dim tempcode string dim tempitem string dim prodcode string dim count long dim lcol long dim trow long dim lasttrow long      source = "invoice"     target = "invoice-record"      lasttrow = sheets(target).range("a" & rows.count).end(xlup).row     trow = lasttrow + 1    'new row on target sheet      'move general invoice info on target     sheets(target).cells(trow, "a") = sheets(source).range("a6").value  'consumer     sheets(target).cells(trow, "b") = sheets(source).range("j5").value  'date     sheets(target).cells(trow, "c") = sheets(source).range("h6").value  'invoice no     sheets(target).cells(trow, "p") = sheets(source).range("j23").value 'net amount      'now establish items have move on      count = 1 12         'looking each of 12 items          prodcode = "i" & count  'set product code based on "i"n  n = count         lcol = count + 3        'the column number 3 more productcode number          lrow = 11 22     'loop through each row on source             if sheets(source).cells(lrow, "a").value > 0                 tempcode = sheets(source).cells(lrow, "c").value    'get temp product code row                  if tempcode = prodcode    'insert qty in column item                     sheets(target).cells(trow, lcol) = sheets(source).cells(lrow, "a")                 end if             end if         next lrow     next count end sub 

invoice record


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -