Hello,
I am trying to write a code that will do the following:
- Search column A in sheet2 for a match to ABC in the code provided.
- if there is a match in column A then select the value in column B of the corresponding row
- The value in column B to be use as an additional name in the new workbook (Infront).
Here is my code:
I am trying to write a code that will do the following:
- Search column A in sheet2 for a match to ABC in the code provided.
- if there is a match in column A then select the value in column B of the corresponding row
- The value in column B to be use as an additional name in the new workbook (Infront).
Here is my code:
Code:
[B][B][B][B][B][B][B]sub split()
extn = inputbox(prompt:="input the extension for file", title:"extension",default:="")
tempname=activeworkbook.name
patt=thisworkbook.path
i=1
do while cells(i,1)<>"base"
i=i+1
loop
i=i+1
do while cells(i,2)<>""
abc=cells(i,2)
a=i
do while cells(i,2)=abc
i=i+1
loop
range(a&":"&i-1).select
selection.copy
set tempWB=workbooks.add(1)
tname=activeworkbook.name
cells(3,1).select
selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks:=false, transpose:=false
selection.pastespecial paste:=xlpasteformats, operation:=xlnone, skipblanks:=false, transpose:=false
workbooks(tempname).activate
rows(2).select
selection.copy
workbooks(tname).activate
cells(2,1).select
selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks:=false, transpose:=false
selection.pastespecial paste:=xlpasteformats, operation:=xlnone, skipblanks:=false, transpose:=false
cells.entirecolumn.autofit
columns("b:B").select
selection.columnwidth=12.14
' Workbook.name=abc
activeworkbook.saveas patt & "\" & abc & "_" & extn
activeworkbook.close
Loop[/B][/B][/B][/B][/B][/B][/B]