Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As per usual, the solution worked excellently. Most appreciated.
M John "sebastienm" wrote: Hi John, Replace the line: Set rg = Range("E1:E500") with : Set rg = Selection If rg is Nothing the exit sub 'no selection If typename(Selection)<"Range" then exit sub 'selection is not range 'Then one *ONLY* of the following section depending on 'what you are looking for: 'Section1: use the first column of the selection even if not column E ' ie Say user selects J20:K50 then use 1st column J20:J50 Set rg= rg.columns(1) 'Section2: use selection projected on column E ' ie Say user selects J20:K50 then use E20:E50 -- same rows on col E Set rg=application.intersect(rg.Range("E:E"), rg.EntireRow) I hope this helps, -- Regards, Sébastien <http://www.ondemandanalysis.com "M John" wrote: Sébastien, Thank you for all your help thus far. My latest difficulty is how to make the code below work for any selected cell.....not just data in the e1:e500 range? Is there a way to make this code work for any/all cells currently selected? Thanks again. You've been an enormous help. M John Dim rg As Range, cell As Range Dim txtpos As Long, txtlen As Long Set rg = Range("E1:E500") For Each cell In rg.Cells txtpos = 1 txtlen = Len(cell.Offset(0, -3).Text) 'length of text in A cell.Characters(1, txtlen).Font.ColorIndex = 3 'color in red txtpos = txtpos + txtlen + 1 ' +1 for the newline character txtlen = Len(cell.Offset(0, -2).Text) 'length of text in B cell.Characters(txtpos, txtlen).Font.ColorIndex = 5 'search for blue, i don't know txtpos = txtpos + txtlen + 1 ' +1 for the newline character txtlen = Len(cell.Offset(0, -1).Text) 'length of text in C cell.Characters(txtpos, txtlen).Font.ColorIndex = 10 'search for green, i don't know txtpos = txtpos + txtlen + 1 cell.WrapText = True Next |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help displaying "Maximum" or "Minimum" if cell is max or min in a group? | Excel Discussion (Misc queries) | |||
VLOOKUP displaying "NO ANSWER" instead of "0" | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! | Excel Discussion (Misc queries) | |||
Make "Edit" mode default, rather than "Enter"? | Excel Discussion (Misc queries) |