Index/Match Macro.

R4yHunt

New Member
Joined
Aug 11, 2018
Messages
3
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:
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]
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top