How to compact code in VBA Macros (Excel) -
i'd make code shorter due getting error "procedure large". how can write code take range a2 a10 1 worksheet, open other worksheet , paste b214 b222 in exact order. right code works well. when make 200 of give me error.
private sub commandbutton1_click() dim ean string worksheets("button excel").select ean = range("a2") worksheets("magic").select worksheets("magic").range("b214").select activecell.value = ean ean = range("a3") worksheets("magic").select worksheets("magic").range("b215").select activecell.value = ean ean = range("a4") worksheets("magic").select worksheets("magic").range("b216").select activecell.value = ean ean = range("a5") worksheets("magic").select worksheets("magic").range("b217").select activecell.value = ean ean = range("a6") worksheets("magic").select worksheets("magic").range("b218").select activecell.value = ean ean = range("a7") worksheets("magic").select worksheets("magic").range("b219").select activecell.value = ean ean = range("a8") worksheets("magic").select worksheets("magic").range("b220").select activecell.value = ean ean = range("a9") worksheets("magic").select worksheets("magic").range("b221").select activecell.value = ean ean = range("a10") worksheets("magic").select worksheets("magic").range("b222").select activecell.value = ean end sub
if need copy values range("a2:a10")
in "button excel" sheet range("b214:b222")
in "magic" sheet, use 1 line of code below:
worksheets("magic").range("b214:b222").value = worksheets("button excel").range("a2:a10").value
Comments
Post a Comment