excel vba - How to check a table range and paste selected values to a new worksheet in VBA? -


i’m trying check rows 63 69 in table 1, if column d value “attivo” , column “f” value >= 130, i'd paste g column value worksheet starting a3 cell. if condition false i’d to pass next row , same check rows, coping , pasting if condition true.

n = 63; lastrow3 = 69.

table 1:

enter image description here

table 2:

enter image description here

sub macroarea1()     dim ws worksheet     dim lastrow long     dim lastrow1 long, lastrow3 long     dim i, n, x integer     set ws = activeworkbook.sheets("report kit")      n = sheets("migrazioni").range("n" & 7).value     lastrow3 = sheets("report kit").range("g" & sheets("report kit").rows.count).end(xlup).row      x = n lastrow3         on error resume next         if sheets("report kit").range("d" & x) = "attivo" , cells(x, 6) >= 130 _         sheets("report kit").range("g" & x).copy         sheets("kit").range("a3").pastespecial xlpastevalues         'else         x = x + 1         'end if     next x  end sub 

for example 1st table input i’d have second table output.

unfortunately vba gives me error (that else condition not ok). guess i’ve built cycle in wrong way. can it, please?

sub macroarea1()     dim ws worksheet     dim lastrow long     dim lastrow1 long, lastrow3 long     dim i, n, x integer, y integer     set ws = activeworkbook.sheets("report kit")      n = sheets("migrazioni").range("n" & 7).value     lastrow3 = sheets("report kit").range("g" & sheets("report kit").rows.count).end(xlup).row     y = 3     x = n lastrow3         sheets("report kit")         if (.cells(x, 4).value2 = "attivo") , (.cells(x, 6).value2 >= 130)             .cells(x, 7).copy             sheets("kit").cells(y, 1).pastespecial xlpastevalues             y = y + 1         end if         x = x + 1         end     next x  end sub 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -