ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looking for a quick way. (https://www.excelbanter.com/excel-programming/386037-looking-quick-way.html)

Michael Koerner

Looking for a quick way.
 
I have roughly 1200 records that I need to change (whatever is here)
including the brackets to italic Any way to do it with a quick macro or is
it going to be a one-at-a-time effort.

--

Regards
Michael Koerner




Ron Coderre

Looking for a quick way.
 
If this is a one-time adjustment, how about this:

Select the range of cells
Hold down [Ctrl] and press [F].....that's a shortcut for <edit<find
Find what: (*)
Click the [Find All] button
-That will list ALL found cells, BUT only select ONE
Hold down [Ctrl] and press [A]....that will select EVERY found cell
Click the [Close] button

Hold down [Ctrl] and press [i].....that's a shortcut to set Italics

Is that something you can work with?
******************
Regards,

Ron


"Michael Koerner" wrote in message
...
I have roughly 1200 records that I need to change (whatever is here)
including the brackets to italic Any way to do it with a quick macro or is
it going to be a one-at-a-time effort.

--

Regards
Michael Koerner






Michael Koerner

Looking for a quick way.
 
Ron;

That would work, but it italicise the whole cell. I just want to italicise
what is bracketed

--

Regards
Michael Koerner


"Ron Coderre" wrote in message
...[i]
If this is a one-time adjustment, how about this:

Select the range of cells
Hold down [Ctrl] and press [F].....that's a shortcut for <edit<find
Find what: (*)
Click the [Find All] button
-That will list ALL found cells, BUT only select ONE
Hold down [Ctrl] and press [A]....that will select EVERY found cell
Click the [Close] button

Hold down [Ctrl] and press .....that's a shortcut to set Italics

Is that something you can work with?
******************
Regards,

Ron


"Michael Koerner" wrote in message
...
I have roughly 1200 records that I need to change (whatever is here)
including the brackets to italic Any way to do it with a quick macro or is
it going to be a one-at-a-time effort.

--

Regards
Michael Koerner








Dave Peterson

Looking for a quick way.
 
It's gonna be a cell by cell effort.

If you only have one set of parens, you may want to look at instr() to find
each.

Option Explicit
Sub testme()
Dim myRng As Range
Dim myCell As Range
Dim StartPos As Long
Dim LastPos As Long

Set myRng = Selection

For Each myCell In myRng.Cells
StartPos = InStr(1, myCell.Value, "(", vbTextCompare)
LastPos = InStr(1, myCell.Value, ")", vbTextCompare)

If StartPos * LastPos 0 Then
If StartPos < LastPos Then
With myCell.Characters _
(Start:=StartPos, Length:=LastPos - StartPos + 1)
.Font.FontStyle = "Italic"
End With
End If
End If
Next myCell

End Sub



Michael Koerner wrote:

I have roughly 1200 records that I need to change (whatever is here)
including the brackets to italic Any way to do it with a quick macro or is
it going to be a one-at-a-time effort.

--

Regards
Michael Koerner


--

Dave Peterson

Dave Peterson

Looking for a quick way.
 
After I posted, I realized that going cell by cell would be a waste if most
cells don't have parentheses in them.

Option Explicit
Sub testme()
Dim myRng As Range
Dim myCell As Range
Dim StartPos As Long
Dim LastPos As Long
Dim FoundCell As Range
Dim FirstAddress As String
Dim AllFoundCells As Range

Set myRng = Selection

With myRng
Set FoundCell = .Find(what:="(", _
LookIn:=xlValues, lookat:=xlPart, _
after:=.Cells(.Cells.Count))

If FoundCell Is Nothing Then
MsgBox "Nothing to fix"
Else
Set AllFoundCells = FoundCell
FirstAddress = FoundCell.Address
Do
If AllFoundCells Is Nothing Then
Set AllFoundCells = FoundCell
Else
Set AllFoundCells = Union(FoundCell, AllFoundCells)
End If
Set FoundCell = .FindNext(FoundCell)

If FoundCell.Address = FirstAddress Then
Exit Do
End If
Loop

For Each myCell In AllFoundCells.Cells
StartPos = InStr(1, myCell.Value, "(", vbTextCompare)
LastPos = InStr(1, myCell.Value, ")", vbTextCompare)

If LastPos 0 Then
If StartPos < LastPos Then
With myCell.Characters(Start:=StartPos, _
Length:=LastPos - StartPos + 1)
.Font.FontStyle = "Italic"
End With
End If
End If
Next myCell

End If

End With

End Sub



Michael Koerner wrote:

I have roughly 1200 records that I need to change (whatever is here)
including the brackets to italic Any way to do it with a quick macro or is
it going to be a one-at-a-time effort.

--

Regards
Michael Koerner


--

Dave Peterson

Michael Koerner

Looking for a quick way.
 
Dave;

Thanks very much, worked like a charm. You don't know how many bottles of
wine you saved me going through if I would have had to do in manually. <g

--

Regards
Michael Koerner


"Dave Peterson" wrote in message
...
After I posted, I realized that going cell by cell would be a waste if
most
cells don't have parentheses in them.

Option Explicit
Sub testme()
Dim myRng As Range
Dim myCell As Range
Dim StartPos As Long
Dim LastPos As Long
Dim FoundCell As Range
Dim FirstAddress As String
Dim AllFoundCells As Range

Set myRng = Selection

With myRng
Set FoundCell = .Find(what:="(", _
LookIn:=xlValues, lookat:=xlPart, _
after:=.Cells(.Cells.Count))

If FoundCell Is Nothing Then
MsgBox "Nothing to fix"
Else
Set AllFoundCells = FoundCell
FirstAddress = FoundCell.Address
Do
If AllFoundCells Is Nothing Then
Set AllFoundCells = FoundCell
Else
Set AllFoundCells = Union(FoundCell, AllFoundCells)
End If
Set FoundCell = .FindNext(FoundCell)

If FoundCell.Address = FirstAddress Then
Exit Do
End If
Loop

For Each myCell In AllFoundCells.Cells
StartPos = InStr(1, myCell.Value, "(", vbTextCompare)
LastPos = InStr(1, myCell.Value, ")", vbTextCompare)

If LastPos 0 Then
If StartPos < LastPos Then
With myCell.Characters(Start:=StartPos, _
Length:=LastPos - StartPos + 1)
.Font.FontStyle = "Italic"
End With
End If
End If
Next myCell

End If

End With

End Sub



Michael Koerner wrote:

I have roughly 1200 records that I need to change (whatever is here)
including the brackets to italic Any way to do it with a quick macro or
is
it going to be a one-at-a-time effort.

--

Regards
Michael Koerner


--

Dave Peterson





All times are GMT +1. The time now is 04:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com