Bold contents of a variable

  • Thread starter Thread starter mikeburg
  • Start date Start date
M

mikeburg

I have a variable assigned a value as follows:

Dim MemberNumber As Integer
Dim MemberName as Text
MemberNumber = Cell
MemberName = Cell.Offset(1, 0)
Cell.Offset(1, 1) = BusinessName & " " & MemberNumber

How can I set the member number to be bolded?

Thanks so very much! mikeburg
 
I presume
Cell.Offset(1, 1) = BusinessName & " " & MemberNumber should be
Cell.Offset(1, 1) = memberName & " " & MemberNumber

I'm not clear which cell you want to make bold, bot one of

Cell.Font.Bold = True
or
Cell.Offset(1,1).Font.Bold = True
should do it.
 
I think the OP wants to make part of the cell Bold and part Normal. I
don't know how to do this from VBA, but then there's a whole lot about VBA
that I don't know.

Bill
---------------------------------
 
A better bit of code is

Cell.Offset(1, 1).Characters(Len(BusinessName) + 1, _
Len(Str(MemberNumber))).Font.Bold = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
I have a variable assigned a value as follows:

Dim MemberNumber As Integer
Dim MemberName as Text
MemberNumber = Cell
MemberName = Cell.Offset(1, 0)
Cell.Offset(1, 1) = BusinessName & " " & MemberNumber

How can I set the member number to be bolded?

Thanks so very much! mikeburg

A little tough to tell what you're doing, since your Dim's don't make sense to
me. But in order to bold a portion of the contents of a cell, the contents
needs to be a text string, and you then use the characters property.

So in your example, to bold MemberNumber, you would use something like:

With [a1].Offset(1, 1)
.Value = businessname & " " & MemberNumber
.Characters(Len(.Value) - Len(MemberNumber) + _
1, Len(MemberNumber)).Font.Bold = True
End With


--ron
 
Thanks a million for your responses.

I was only wanting to bold the member number part of the cell.

Your replies were working but the BusinessNumber was not bolding when
the BusinessName was sometimes blank (no business name existed), but
the last reply worked great!

Thanks so much. mikeburg
 
Thanks a million for your responses.

I was only wanting to bold the member number part of the cell.

Your replies were working but the BusinessNumber was not bolding when
the BusinessName was sometimes blank (no business name existed), but
the last reply worked great!

Thanks so much. mikeburg


Glad to help. Thanks for the feedback.


--ron
 
Both of Chip's worked for me whether Cell.Offset(1,0) was empty or not when
I corrected your code to use the correct variable name.


Maybe a little more thorough testing on your part would be beneficial.
 

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