Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Bold & increase font size of inStr(...) character's position

OneRng values are numbers 1 to 9, such as 123, 124567, 3, 123456789, 456.

If Range("P1") = 3 then I want the 3 in each cell that has a 3, for the 3 to be BOLD and font size to 14.

My change code MsgBox correctly returns the POSITION of the P1 value in each cell of OneRng.

I can't figure how to use that to do a FONT & BOLD for that position.

Thanks.
Howard

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target < Range("P1") Then Exit Sub

Dim OneRng As Range, c As Range
Dim pInt As Long, pPos As Long

pInt = Range("P1")
Set OneRng = Range("E2:M10")

For Each c In OneRng
If InStr(c, pInt) 0 Then
pPos = InStr(c, pInt)

MsgBox pPos

Else
End If
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Bold & increase font size of inStr(...) character's position

Hi Howard,

Am Sat, 8 Aug 2015 23:53:07 -0700 (PDT) schrieb L. Howard:

OneRng values are numbers 1 to 9, such as 123, 124567, 3, 123456789, 456.

If Range("P1") = 3 then I want the 3 in each cell that has a 3, for the 3 to be BOLD and font size to 14.


to format a substring is only possible with TEXT, not with NUMBERS.
If you don't want to calculate with the values you can change it to
text.
Try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E2:M10")) Is Nothing _
Or Target.Count 1 Then Exit Sub

Dim pInt As String

Range("E2:M10").NumberFormat = "@"
pInt = Range("P1")

With Target
With .Characters(InStr(.Text, pInt), 1)
.Font.Bold = True
.Font.Size = 14
End With
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Bold & increase font size of inStr(...) character's position



to format a substring is only possible with TEXT, not with NUMBERS.
If you don't want to calculate with the values you can change it to
text.
Try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E2:M10")) Is Nothing _
Or Target.Count 1 Then Exit Sub

Dim pInt As String

Range("E2:M10").NumberFormat = "@"
pInt = Range("P1")

With Target
With .Characters(InStr(.Text, pInt), 1)
.Font.Bold = True
.Font.Size = 14
End With
End With
End Sub


Regards
Claus B.


Hi Claus,

Aha, more complicated than I thought.

I should have included in my first post that cell P1 is a drop down with the 1 to 9 numbers, and when I select a number in P1 it is a single digit from 1 to 9, then all the same numbers as P1 in the E2:M10 range are bold and font size 14.

So the Target is range P1.

The numbers are NOT for calculating either in P1 or the E2:M10 range.

Howard

I'm trying to reassemble your code but not making much progress.

Howard
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Bold & increase font size of inStr(...) character's position

Hi Howard,

Am Sun, 9 Aug 2015 01:59:58 -0700 (PDT) schrieb L. Howard:

I should have included in my first post that cell P1 is a drop down with the 1 to 9 numbers, and when I select a number in P1 it is a single digit from 1 to 9, then all the same numbers as P1 in the E2:M10 range are bold and font size 14.

So the Target is range P1.


then try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) < "P1" Or Target.Count 1 Then Exit Sub

Dim OneRng As Range, rngC As Range
Dim PInt As String, pos As Long

Set OneRng = Range("E2:M10")
OneRng.Font.Bold = False
PInt = Range("P1")

For Each rngC In OneRng
pos = InStr(CStr(rngC.Value), PInt)
With rngC
If pos 0 Then
.NumberFormat = "@"
With .Characters(pos, 1)
.Font.Bold = True
.Font.Size = 14
End With
End If
End With
Next

End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Bold & increase font size of inStr(...) character's position


I should have included in my first post that cell P1 is a drop down with the 1 to 9 numbers, and when I select a number in P1 it is a single digit from 1 to 9, then all the same numbers as P1 in the E2:M10 range are bold and font size 14.

So the Target is range P1.


Hi Claus,

I think I am still misleading you with bad directions.

Here is a sample column of nine the columns in the OneRng.

1367
167
4
139
1379
1489
2
135
8


If P1 = 4 then the single 4 and the 4 in 1489 should both be bold and font 14.

It is only affecting the lone digit 4 as written.

Howard




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Bold & increase font size of inStr(...) character's position

Hi Howard,

Am Sun, 9 Aug 2015 03:08:02 -0700 (PDT) schrieb L. Howard:

Here is a sample column of nine the columns in the OneRng.

1367
167
4
139
1379
1489
2
135
8

If P1 = 4 then the single 4 and the 4 in 1489 should both be bold and font 14.



look he
https://onedrive.live.com/redir?resi...121822A3%21326
for "Format_Substrings"


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Increase font size in a check box RBailey Excel Discussion (Misc queries) 0 March 13th 08 04:53 PM
Number in cell increase with increase in font size. Value increases with increase in font.[_2_] Excel Discussion (Misc queries) 2 August 9th 07 01:58 PM
Can you keep a cells BOLD Font, cell color size Trese Excel Discussion (Misc queries) 2 August 23rd 05 03:09 PM
change font size and bold in cell? R Doornbosch Excel Programming 7 February 10th 04 12:03 AM
Changing font size, bold and underline ChuckM[_2_] Excel Programming 1 December 17th 03 02:12 PM


All times are GMT +1. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"