excel vba - VBA Loop and copy regions from sheet to sheet -
i trying loop down column "q" on active sheet, find values in between 27 , 40 , copy cell along region around cell noted (-1, -16) new sheet.
right making region bold make sure loop catching right values , regions.
i"m new vba if can give me pointers or advise on how solve problem i'd appreciative.
sub test2() application.screenupdating = false activesheet.range("q13").select let x = 0 while x < 500 if activecell.value >= 27 , activecell.value <= 40 range(activecell, activecell.offset(-1, -16)).select selection.font.bold = true activecell.offset(2, 16).activate else activecell.offset(1, 0).select end if x = x + 1 loop end sub
try below code :
sub test2() application.screenupdating = false dim lastrow long lastrow = sheets("sheet1").range("q" & rows.count).end(xlup).row dim rng range, cell range set rng = sheets("sheet1").range("q1:q" & lastrow) each cell in rng if cell.value >= 27 , cell.value <= 40 sheets("sheet1").range(cell, cell.offset(0, -16)).copy sheets("sheet2").cells(sheets("sheet2").range("q" & rows.count).end(xlup).row + 1, 1) end if next application.screenupdating = true end sub
Comments
Post a Comment