Combining Columns (Bracketing Text)

  • Thread starter Thread starter Michael Koerner
  • Start date Start date
M

Michael Koerner

I have a need to combine two columns, which I can do using the features from
PUP 6. What I would like to know how to do before I combine the columns, if
any of the cells in one column, (bracket) that information before combining
 
Think you left something out of your statement

If any of the cells in one column ? ? ?,

Also, What do you mean by bracket?

Do you want to indicate missing values by putting brackets in the string

"AAA" & "()"

If you physically want to put in the brackets

Dim rng as Range, rng1 as Range
set rng = Intersect(Range("A:B"),Activesheet.UsedRange)
On Error Resume Next
set rng1 = rng.Specialcells(xlBlanks)
On error goto 0
if not rng1 is nothing then
rng1.Value = "()"
End if
 
Sorry about that I should have read more closely what I wrote, and should
not compose until I have had my first coffee <g>

In col B, if there is data in any of the cells, then put it into (brackets)
 
Sub AddBrackets()
Dim rng as Range, cell as Range
set rng = Columns(2).SpecialCells(xlConstants)
for each cell in rng
if len(trim(cell)) > 0 then
cell.Value = "(" & cell.Value & ")"
end if
Next
End Sub
 
Tom;

That worked great, thank you very much. What would I have to change to make
it work on any column I happen to be in?
 
Sub AddBrackets()
Dim rng as Range, cell as Range
On error resume Next
set rng = ActiveCell.EntireColumn.SpecialCells(xlConstants)
On error goto 0
if not rng is nothing then
for each cell in rng
if len(trim(cell)) > 0 then
cell.Value = "(" & cell.Value & ")"
end if
Next
end if
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

Back
Top