Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi Guyz,
I have new challenge at my work and still i am asking your kindness to lend me some code to be able to finish this task. By the way, the code i have here is derived from previous topics here but still i am lacking the gift to accomplish what i want. Here's the scenatio, i am getting five words from six different cells. The words from these cells are linked from other tabs within my workbook except for one word in which it is hard coded. Here's what i want to happen, when the macro is run the string result is stated below; Bold not-bold bold not-bold bold not-bold (six words concatinated). Words in bold font style will show alternating. And here's my struggling codes below; Sub Try() Dim myRangeA1 As String 'Dim myRangeA2 As String Dim myRangeA3 As String Dim myRangeA4 As String Dim myRangeA5 As String Dim myRangeA6 As String myRangeA1 = Sheets("Diary").Range("A1") 'myRangeA2 = Sheets("Diary").Range("A2") myRangeA3 = Sheets("Diary").Range("A3") myRangeA4 = Sheets("Diary").Range("A4").Text myRangeA5 = Sheets("Diary").Range("A5") myRangeA6 = Sheets("Diary").Range("A6").Text With Range("A5") .Value = myRangeA1 & " " & "not Bold" & " " & myRangeA3 & " " & myRangeA4 & " " & myRangeA5 & " " & myRangeA6 .Characters(1, Len(myRangeA1)).Font.Bold = True .Characters(1 + Len(myRangeA1) + Len(myRangeA3)).Font.Bold = True End With End Sub Hoping or your kind consideration :-) Thanks, jerome |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think you will have to use a loop. Put your concatenated string in a
range, then loop with the characters first letter and length as variables that change on each loop. The code below is based on a fixed length text in each concatenated cell of five characters. If you have varying lengths per cell, then this method will not work. Sub bldFnt() myVar = Range("A1").Value & " " & Range("A2").Value & " " & _ Range("A3").Value & " " & Range("A4").Value & " " & _ Range("A5").Value & " " & Range("A6").Value With Sheets(1).Range("A7") .Value = myVar For i = 1 To 31 Step 12 .Characters(i, 6).Font.Bold = True Next End With End Sub "jhong" wrote: hi Guyz, I have new challenge at my work and still i am asking your kindness to lend me some code to be able to finish this task. By the way, the code i have here is derived from previous topics here but still i am lacking the gift to accomplish what i want. Here's the scenatio, i am getting five words from six different cells. The words from these cells are linked from other tabs within my workbook except for one word in which it is hard coded. Here's what i want to happen, when the macro is run the string result is stated below; Bold not-bold bold not-bold bold not-bold (six words concatinated). Words in bold font style will show alternating. And here's my struggling codes below; Sub Try() Dim myRangeA1 As String 'Dim myRangeA2 As String Dim myRangeA3 As String Dim myRangeA4 As String Dim myRangeA5 As String Dim myRangeA6 As String myRangeA1 = Sheets("Diary").Range("A1") 'myRangeA2 = Sheets("Diary").Range("A2") myRangeA3 = Sheets("Diary").Range("A3") myRangeA4 = Sheets("Diary").Range("A4").Text myRangeA5 = Sheets("Diary").Range("A5") myRangeA6 = Sheets("Diary").Range("A6").Text With Range("A5") .Value = myRangeA1 & " " & "not Bold" & " " & myRangeA3 & " " & myRangeA4 & " " & myRangeA5 & " " & myRangeA6 .Characters(1, Len(myRangeA1)).Font.Bold = True .Characters(1 + Len(myRangeA1) + Len(myRangeA3)).Font.Bold = True End With End Sub Hoping or your kind consideration :-) Thanks, jerome |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
why does it only bold the number in red when i apply the % style? | Excel Discussion (Misc queries) | |||
Bold Font | Excel Discussion (Misc queries) | |||
How to count number of Cell have Strike Through Effect & Bold as font style. | Excel Discussion (Misc queries) | |||
How to count number of Cell have Strike Through Effect & Bold as font style. | Excel Programming | |||
Bold Font | Excel Programming |