button awareness. i dont know if it can be done.

C

cdde

well....its a spreadsheet that has my products on it....and we offer
different colors for each product.....so instead of have a thousand
lines of products to choose from....we just have one that you can
specify color.....the button next to the row adds a second line of the
same product on the next row down...so they can have 2 or more colors
on the same item......

so i just want the button to duplicate the row on the next row down.
and im trying to get it so i dont have to have 250+ macro's with only a
model number in the code differing them.....i just want one macro that
can tell what button activated it and duplicate just that one item.
hope that helps....

heres my code so far.....but its the code for only one product of 250+

sub add_line_item()
application.screenupdating = false
dim foundcell as range

with activesheet.range(\"a:a\")
set foundcell = .find(what:=\"ga1078\", _
after:=.cells(.cells.count), _
lookin:=xlformulas, lookat:=xlpart, _
searchorder:=xlbyrows, searchdirection:=xlnext, _
matchcase:=false)
end with

if foundcell is nothing then
msgbox \"can not add more.\"
else
foundcell.select
end if

activecell.offset(1, -activecell.column + 1).select
activecell.entirerow.select
selection.insert shift:=xldown
foundcell.select
selection.resize(1, 12).select
selection.copy
foundcell.select
activecell.offset(1, -activecell.column + 1).select
selection.resize(1, 12).select
activesheet.paste
application.cutcopymode = false
foundcell.select
activecell.offset(1, -activecell.column + 1).select
selection.resize(1, 12).select
selection.borders(xldiagonaldown).linestyle = xlnone
selection.borders(xldiagonalup).linestyle = xlnone
with selection.borders(xledgeleft)
linestyle = xldashdot
weight = xlthin
colorindex = xlautomatic
end with
with selection.borders(xledgetop)
linestyle = xldashdot
weight = xlthin
colorindex = xlautomatic
end with
with selection.borders(xledgebottom)
linestyle = xldashdot
weight = xlthin
colorindex = xlautomatic
end with
with selection.borders(xledgeright)
linestyle = xldashdot
weight = xlthin
colorindex = xlautomatic
end with
foundcell.select
activecell.offset(1, -activecell.column + 1).select
selection.interior.colorindex = 37
activecell.offset(0, 8).select

application.screenupdating = true
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top