excel - Macro Do Until Loop Copy from list of values paste into single cell (e.g. b1) -
this first post here, in advance help. great community!
i trying write macro loop through list of values of undetermined number of rows , 1 one copy , paste values single cell, each time through loop replacing value pasted single cell, referenced report template , auto-populates data based on id of number
here example of table like:
__|__a__|__b__ 1 | 231 | 234 2 | 232 | 3 | 233 | 4 | 234 | 5 | 235 | 6 | 236 |
231 copied , pasted b1, 232 copied , pasted b1, 233 copied , pasted b1, 234 copied , pasted b1.....and on , forth. in between copy , past steps there other steps add images worksheet , save pdf.
i wrote script accomplish goal:
sub report() ' ' report macro ' ' keyboard shortcut: ctrl+shift+g ' ' section copies selection of cells on worksheet , moves worksheet filters , copies filtered list yet worksheet. application.screenupdating = false selection.copy sheets("master sheet").select range("a6").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false activesheet.range("$a$5:$bs$410").autofilter field:=7, criteria1:="2" selection.copy sheets("report").select range("a1").select activesheet.paste ' section operation outlined @ beginning of post. range("a1").select until isempty(activecell.value) selection.copy range("b1").select activesheet.paste application.run "personal.xlsb!erasephoto" application.run "personal.xlsb!photoplace" activewindow.scrollrow = 1 application.cutcopymode = false chdir "c:" activesheet.exportasfixedformat type:=xltypepdf, filename:=range("b3").value _ , quality:=xlqualitystandard, includedocproperties:=true, ignoreprintareas _ :=false, openafterpublish:=true application.run "personal.xlsb!erasephoto" activecell.offset(1, 0).select loop end sub
when run macro goes through once successfully, doesn't loop. i'm not sure why? thanks!!!!
step through code see cells active cells when loop executed? code sets b1 active cell in each loop. without knowing called procedures do, it's hard tell cell affected activecell.offset(1, 0).select
before loop.
the code has lot of unnecessary selects , activate statements. clean up.
Comments
Post a Comment