excel vba - Enter a number into a message box then replace numbers in a macro -


i have following macro. when run macro message box appear asking file number. file number replace 000 in macro , macro run.

application.screenupdating = false  range("c4:d4").select activecell.formular1c1 = "000"  sheets("sale ()").select sheets("sale ()").name = "sale (000)"  activeworkbook.save  sheets("sale (000)").copy before:=workbooks("sales index.xls").sheets(2)  windows("sales index.xls").activate sheets("index").select range("b3").select selection.entirerow.insert range("a3").select activecell.formular1c1 = "000" range("a3").select activesheet.hyperlinks.add anchor:=selection, address:="", subaddress:= _     "'sale (000)'!c9" selection.font.underline = xlunderlinestylenone range("b4:f4").select selection.copy range("b3").select activesheet.paste application.cutcopymode = false activecell.formular1c1 = "='sale (000)'!r9c3" range("b3:f3").select range("c3").activate activecell.formular1c1 = "='sale (000)'!r3c36" range("b3:f3").select range("d3").activate activecell.formular1c1 = "='sale (000)'!r3c44" range("b3:f3").select range("e3").activate activecell.formular1c1 = "='sale (000)'!r5c36"  application.screenupdating = true  sheets("sale (000)").select 

insert @ top:

dim st string st = application.inputbox(prompt:="enter file number", type:=2) 

and replace carefully 000

for example:

activecell.formular1c1 = st 

even though st string, can enter values 000 , have characters preserved.

edit#1

another example

replace:

"='sale (000)'!r9c3" 

with

"='sale (" & st & ")'!r9c3" 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -