Hi all,
I wanted to try a formula, so here's one I am sure can be improved on. If the UDF is more to the liking, please note that both columns get selected when typing in the SPLITCELL function, and confirmed by CSE.
Sheet1
<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Arial,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD> </TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-TOP: #0000ff 2px solid; BORDER-LEFT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">Test5123</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-TOP: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">Test</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-TOP: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid; TEXT-ALIGN: right">5123</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-TOP: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid"> </TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-TOP: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">Test</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-TOP: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid; TEXT-ALIGN: right">5123</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-LEFT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">abc2011</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">abc</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid; TEXT-ALIGN: right">2011</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid"> </TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">abc</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid; TEXT-ALIGN: right">2011</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">4</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-LEFT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid"> </TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid"> </TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid"> </TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid"> </TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">NEG</TD><TD style="BORDER-RIGHT: #0000ff 2px solid; BORDER-BOTTOM: #0000ff 2px solid">NEG</TD></TR></TBODY></TABLE>
<TABLE style="FONT-SIZE: 10pt; BORDER-LEFT-COLOR: #00ff00; BORDER-BOTTOM-COLOR: #00ff00; COLOR: #000000; BORDER-TOP-STYLE: groove; BORDER-TOP-COLOR: #00ff00; FONT-FAMILY: Arial; BORDER-RIGHT-STYLE: groove; BORDER-LEFT-STYLE: groove; BACKGROUND-COLOR: #fffcf9; BORDER-RIGHT-COLOR: #00ff00; BORDER-BOTTOM-STYLE: groove"><TBODY><TR><TD>
Spreadsheet Formulas</TD></TR><TR><TD><TABLE style="FONT-SIZE: 9pt; FONT-FAMILY: Arial" cellSpacing=0 cellPadding=2 border=1><TBODY><TR style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #cacaca"><TD>Cell</TD><TD>Formula</TD></TR><TR><TD>B2</TD><TD>{=MID(A2,1,MIN
(IF(ISERR(SEARCH("%",SUBSTITUTE(A2,{0,1,2,3,4,5,6,7,8,9},"%"),1)),99,SEARCH("%",SUBSTITUTE(A2,{0,1,2,3,4,5,6,7,8,9},"%"),1)))-1)}</TD></TR><TR><TD>C2</TD><TD>{=MID(A2,MIN
(IF(ISERR(SEARCH("%",SUBSTITUTE(A2,{0,1,2,3,4,5,6,7,8,9},"%"),1)),99,SEARCH("%",SUBSTITUTE(A2,{0,1,2,3,4,5,6,7,8,9},"%"),1))),99)}</TD></TR><TR><TD>E2</TD><TD>{=SPLITCELL(A2)}</TD></TR><TR><TD>F2</TD><TD>{=SPLITCELL(A2)}</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
Rich (BB code):
Option Explicit
Function SplitCell(ByVal CellVal As String) As Variant()
Static REX As Object
Dim Match As Object
If REX Is Nothing Then Set REX = CreateObject("VBScript.RegExp")
With REX
.Global = False
.Pattern = "([^0-9]*)([0-9]+)"
If .test(CellVal) Then
Set Match = .Execute(CellVal)(0)
SplitCell = Array(Match.submatches(0), Match.submatches(1))
Else
SplitCell = Array("NEG", "NEG")
End If
End With
End Function
Hope that helps,
Mark