excel - Macro loop to pull data from sheet to sheet stopping when no data resent and not entering 0 -


i trying data rows g,h, , row 15 down (stopping when there no data present)from "order sheet", pasted in sheet called “data” in columns m,q , r row 8 down.

i have tried recording macro, data changes day day, recorded macro stays same , don’t have know how place if formula in macro stop when there no data in origin cell. 1 day data row 15 50 in order sheet , next 15 71 (always starts @ 15). when macro 200 rows cover rows no matter how many rows may be, itll places 0 in data sheet when nothing present in order sheet cell. leave blank if there no number in order sheet cell.

e.g. “order sheet” column paste “data sheet” (starting row 15 down on order sheet , row 8 down on data sheet) g m / h q / r

e.g. g15 m8 / h16 q9 / i17 r10

see basic recorder macro idea.

thanks in advance

activewindow.smallscroll down:=-15 range("m8").select activecell.formular1c1 = "='order sheet'!r[7]c[-6]" range("m8").select selection.autofill destination:=range("m8:m159"), type:=xlfilldefault range("m8:m159").select activewindow.smallscroll down:=-135 range("q8").select activecell.formular1c1 = "='order sheet'!r[7]c[-9]" range("q8").select selection.autofill destination:=range("q8:q159"), type:=xlfilldefault range("q8:q159").select activewindow.smallscroll down:=-132 range("r8").select activecell.formular1c1 = "='order sheet'!r[7]c[-9]" range("r8").select selection.autofill destination:=range("r8:r159"), type:=xlfilldefault range("r8:r159").select activewindow.smallscroll down:=-123 range("i3").select 

here way copy values g15 downwards m8 downwards

dim sourcesht worksheet 'sheet want copy  dim targetsht worksheet 'sheet want copy dim sourcerng range 'what want copy dim targetrng range 'where want copy dim lastrow long 'the last row holds data  set sourcesht = sheets("order sheet") set targetsht = sheets("data")  sourcesht     lastrow = .cells(.rows.count,7).end(xlup).row '7 column number end  set sourcerng = sourcesht.range("g15:g" & lastrow) set targetrng = targetsht.range("m8").resize(sourcerng.rows.count, 1) ' range("m8:m"& lastrow - 7) possible targetrng.value = sourcerng.value 

you might want introduce variables hold column indices , row numbers (like 15 , 8). have ranges contain more 1 column copy more data @ once.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -