Help with simple(?) VBA function

I'm trying to selectively BOLD cells by the use of a User-Defined function.
No joy.

The VBA Help topics suggest something like this:

    Function Bold()
        Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
    End Function

When I try to use it the referenced cells are not changed and the function
returns "0".

Can anyone point this VBA neophyte in the right direction?

Thanks,

    -Dick-



0
dicko (2)
3/7/2004 8:55:03 PM
excel.newusers 15348 articles. 2 followers. Follow

4 Replies
656 Views

Similar Articles

[PageSpeed] 5

Hi Dick,
A function can only return a value.

    Macros and Functions  (Macros as Opposed to Functions)
    http://www.cpearson.com/excel/differen.htm

If all you want to do is bold 5 cells,  easier to do just do that
manually, but you can do that with a subroutine..

--
HTH,
David McRitchie, Microsoft MVP - Excel    [site changed  Nov. 2001]
My Excel Pages:  http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page:        http://www.mvps.org/dmcritchie/excel/search.htm

"Dick Merryman" <dicko@wormhole.com> wrote in message news:w9KdnRdv0b66EdbdRVn-gw@comcast.com...
> I'm trying to selectively BOLD cells by the use of a User-Defined function.
> No joy.
>
> The VBA Help topics suggest something like this:
>
>     Function Bold()
>         Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
>     End Function
>
> When I try to use it the referenced cells are not changed and the function
> returns "0".
>
> Can anyone point this VBA neophyte in the right direction?
>
> Thanks,
>
>     -Dick-
>
>
>


0
dmcritchie (2586)
3/7/2004 9:02:32 PM
Hi dick
no chance to do this. Functions are not able to change the Excel
environment. E.g. they cannot change other cells or formats. They can
only return values.

--
Regards
Frank Kabel
Frankfurt, Germany

Dick Merryman wrote:
> I'm trying to selectively BOLD cells by the use of a User-Defined
> function. No joy.
>
> The VBA Help topics suggest something like this:
>
>     Function Bold()
>         Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
>     End Function
>
> When I try to use it the referenced cells are not changed and the
> function returns "0".
>
> Can anyone point this VBA neophyte in the right direction?
>
> Thanks,
>
>     -Dick-

0
frank.kabel (11126)
3/7/2004 9:04:09 PM
Dick

Functions cannot change formatting, only return results.

Try

Sub Bold()
     Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
End Sub

Gord Dibben Excel MVP

On Sun, 7 Mar 2004 15:55:03 -0500, "Dick Merryman" <dicko@wormhole.com> wrote:

>I'm trying to selectively BOLD cells by the use of a User-Defined function.
>No joy.
>
>The VBA Help topics suggest something like this:
>
>    Function Bold()
>        Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
>    End Function
>
>When I try to use it the referenced cells are not changed and the function
>returns "0".
>
>Can anyone point this VBA neophyte in the right direction?
>
>Thanks,
>
>    -Dick-
>
>

0
Gord
3/7/2004 9:58:18 PM
Guys, thanks for the responses.  I did not know that functions were so
limited.

Let me tell you what I am trying to do and maybe you'll have some
suggestions.

I have a spreadsheet that lists manufacturing production options and their
associated costs.  What I want to do is select various options by putting an
"x" next to the option and having Excel highlight the option description in
bold and sum the cost into the grand total.  I have it all working except
for the bold highlighting.

Any help??

    -Dick-


"Dick Merryman" <dicko@wormhole.com> wrote in message
news:w9KdnRdv0b66EdbdRVn-gw@comcast.com...
> I'm trying to selectively BOLD cells by the use of a User-Defined
function.
> No joy.
>
> The VBA Help topics suggest something like this:
>
>     Function Bold()
>         Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
>     End Function
>
> When I try to use it the referenced cells are not changed and the function
> returns "0".
>
> Can anyone point this VBA neophyte in the right direction?
>
> Thanks,
>
>     -Dick-
>
>
>


0
dicko (2)
3/7/2004 11:31:37 PM
Reply:

Similar Artilces:

Formula help #3
Sheet1 has a name in A1 & a number in B1, name in A2 number in B2 and s on (numbers will continually be changed). On sheet2 I used =a or = and so on (the results of =a or =b are the names from sheet 1). Wha I want to accomplish is every time I type =a or =b and the name appear I also want the result from sheet1 B1 and so on to appear in the cel directly below. Not very experienced just learning. Looking fo help -- Message posted from http://www.ExcelForum.com Hi Ljsimm You post is a bit vague, but if you mean you want B1 on sheet 2 to match up with the name on Sheet 1. Try: =IF(...

HELP! #2
I just had a cluster failover and fail back and for whatever reason, now when users go into Outlook and type the name of a public folder or newsgroup on the To: line they see the name of the group plus some sort of SID looking string next to it. For example, instead of just seeing thename of the group they are seeing: company.newsgroupname <newsgroupname34239492038902385092845923> What's going on? Help! Dan Dan, Are there any errors in the event logs pertaining to access of AD or anything like that? C. Smith Enso Technologies, Incorporated http://www.ensotech.com On Wed,...

Iterative Calculation help needed
I have the following information A1 - Balance at the beginning of calculation A2 - Annualized payment A3 - Interest rate divided by # of payments per year A4 - Number of years * # of payments per year I'm trying to calulate the total ((A1-A2)*(1+A3)) - I need to do this over and over up until I've don it A4 times. I can do it for each period but I want to do it all in one cell, i possible. How can I have it plug the new number into A1 and repeat th calculation A4 times. Thanks -- Message posted from http://www.ExcelForum.com Hi there You might find that the PMT function coul...

i am receiving every emai twice?? can anyone help with this issue
I would appreciate any advice cheers, See http://www.howto-outlook.com/faq/duplicates.htm -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://www.msoutlook.info/ Real World Questions, Real World Answers ----- "ETA" <ETA@discussions.microsoft.com> wrote in message news:5939A41A-2CBC-415A-BA84-C14C2FD19084@microsoft.com... > I would appreciate any advice > > cheers, ...

Lookup Function in user form
I have a combo box (cboitem1) and a text box (txtprice1). I am using the code below to have txtprice1 fill with the corresponding price the worksheet: Private Sub Cboitem1_Change() If cboItem1 <> "" Then txtprice1.Value = Excel.WorksheetFunction.VLookup(cboItem1.Value, Sheets("Pizzas").Range("A1:B65536"), 2, False) End If End Sub It works perfectly when you enter an existing value in cboitem1. However if 'the user' accidently types a letter that is not the first letter of one of the existing items VB debugging pops up with error &qu...

Track in CRM function
Hello. Upon selecting the “Track In CRM” button from the CRM line in Outlook I have two questions based on situation: 1) If the contact exists in CRM it appears to attach the email but provides no notice unless you try to attach it again? True? 2) If the contact does not exist it attaches the email where? In v1.2 it opened a window and made the user create a record. I think it is attaching or tracking the email in CRM somewhere because trying to do it again, I'm asked if you want to attach/track it again. Does this make sense? By the way, we are using CRM 3.0 Thanks. After c...

Need HELP with Exchange Restore/Recovery
Details: 2003 sp2 Exchange Server Enterprise 2003 sp1 Server Enterprise C: drive is 100GB Logical Drive over x4 36GB drives in a RAID 5 set D: drive is 280GB Logical Drive over x5 70GB drives in a RAID 5 set Domain Controller Last night I upgraded our 2003 sp1 Exchange to sp2 + any O/S hot fixes and DST fix. No problem with the upgrade or hot fix, but @ about 200 a.m. I lost two of the five drives in the RAID 5 set (drive D) that had the exchange install. I’m currently replacing the hardware & bringing up the drives & going to recreate the D: drive. (server is bootable) I h...

Tracked changes function misbehaving
I have a simple workbook (2002) in which the Track Changes feature is enabled. End users have reported periodic problems with the contents of cells "mysteriously" changing. In process of investigating these, have found that when tracked changes are highlighted, the comments that describe changes are not always associated with the correct cell. Example, comment on cell B114 states "Changed cell B114 from '<blank>' to '12345'". In fact, contents of cell B114 is "67890" and contents of cell B104 is actually "12345". Has anyone...

Help!! Need Recovery!
So I went to open my excell file as usual and suddenly I have 10 or so instances openned. As I was closing them I saved one that turned out to be an old version, REAL OLD, like 2 weeks or so. No I desparataly need to get back to where I was. I tried to use the recovery utility under Microsoft Tools, but there are no available dates to revert to. I have no other way of reverting the document. Anyone know what to do? Any help would be greatly appreciated! Thank you.- Kjellster :D ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and ...

Sloooow. PLEASE HELP
Hi All, I have two questions first is where do I find the Windows 7 Disscussion Group. Have posted here because was unable to locate the windows 7 Discussion Group. My computer which is a SAMSUNG N110 3 months old has become very very very slow. It has Windows 7 installed I have upgraded the memory to two GIG. I have antivirus software and Anti Malware bytes installed. The problem i have is that the machine seems to slow down and sometimes crash whenever I click on internet explorer and many other applications such as office 2007 etc, etc. I have run the Norton Virus pr...

VBA Code to Open File1; Open File2 copy sheets to File1
Using XL 2003 & 97 Need help with the following VBA code: Sub Macro1() Dim myNewWorkbook As String myNewWorkbook = ActiveWorkbook.Name Workbooks.Open Filename:="OldWorkbookFile.xls" Sheets(Array("Formulas", "Department Lables")).Activate Sheets(Array("Formulas", "Department Lables")).Copy _ Before:=Workbooks(myNewWorkbook).Sheets(2) Windows("OldWorkbookFile.xls").Activate ActiveWorkbook.Close Windows(myNewWorkbook).Activate ' ........ End Sub My goal is to have myNewWorkbook active then:...

Help to build a table
Please help me to build a table similar to this one The number on the first column will change after 16 times, it will go in sequence from 1001, 1002, etc… The number in the second column will change after 4 times and it will go from 1 to 4 The number in the 3rd column will go from 1 to 4 2nd and 3rd column will keep the same pattern. Cabinet Shelf Location 1001 1 1 1001 1 2 1001 1 3 1001 1 4 1001 2 1 1001 2 2 1001 2 3 1001 2 4 1001 3 1 1001 3 2 1001 3 3 1001 3 4 1001 4 1 1001 4 2 1001 4 3 1001 4 4 1002 1 1 1002 1 2 1002 1 3 1002 1 4 1002 2 1 1002 2 2 1002 2...

List of kernel mode compatible functions
Hi, Is there a list of kernel mode compatible C/C++ functions (preferably for WDK 7600)? Thanks, Jan Wouldn't that be the WDK Help file? Thomas F. Divine "Jan M" <jan_m@jerseymail.co.uk> wrote in message news:e7fhXcanKHA.1548@TK2MSFTNGP02.phx.gbl... > Hi, > > Is there a list of kernel mode compatible C/C++ functions (preferably for > WDK 7600)? > > Thanks, > > Jan > Your right of course. I just didnt look hard enough. Jan ...

Set Out of Office (or a rule) to only function on weekends
Hello, I am trying to set up so that every weekend my internal e-mail gets forwarded to my home(smartphone) account. I can only find options to run a rule or out of office assistant to run for specific date ranges. How do I set up either a rule or the out of office assistant to 'push' mail to me only on weekends? HCA.CWT.RN wrote on Fri, 02 April 2010 09:04 > Hello, I am trying to set up so that every weekend my internal e-mail gets > forwarded to my home(smartphone) account. I can only find options to run a > rule or out of office assistant to run for spec...

FORECASTING SALES (please let this be a worksheet function)
Hi I have recently been given the task by my boss to forecast one of ou key customers monthly usage until monthly until end of 2006, I am starting with this customers indidual branches monthly usage fo the past 3 years, Some branches will have opened and closed during thi time, And i am looking to be able to predict monthly usage for the nex 18 months Has anyone got any idea's on the best way to forcast within excel, I a currently using trend (fomulae given to me on this sight) but people ar saying this is not the best way Exponentionally has been mentioned by a few of my collegues but...

Help writing a formula
I have a huge database that I need to create numbering for each line like this example: AK-233 (2 letter state, a dash, and 1-4 digit number), but the number doesn't change each line - sometimes the number will be duplicated on multiple lines because those lines have the same title, I also need to create another cell extending that letter/number combo that will differentiate the 1st cell. So the first cell stays the same if the title is the same. The second cell adds another layer of numbering to differentiate the first cell. See example: (Row1, Col 1-4) AK-1, AK-1-1, Title1...

My computer has stopped recognizing my memory card
This just happened today. The card was purchased the day after Thanksgiving so it's very new. It is a 4GB SD card from HP. I don't believe this is a hardware problem as my digital camera Lexar 1GB Memory Stick Duo card and adapter worked just fine today in the same slot. There has been no damage to the card. It has a write-protection lock on the side and I've tried the card with and without the lock on - neither way worked. I've also checked "My Computer" and confirmed that the computer is not listing my card as a drive any longer. I really need to get t...

Using a OR() like function in an IIF statement
Hello, I am trying to create an IIF statement to test if the first character in a field is a 1,2,8 or 9. Something like the following: IIf(Left([possible_SO_match],1)="1 or 2 or 8 or 9",[Possible_SO_Match],"No Match") Is there a way to create it without going to a 4 level nested IIF statement? Thanks, Kerry -- Message posted via http://www.accessmonster.com kkulakow via AccessMonster.com wrote: > Hello, I am trying to create an IIF statement to test if the first > character in a field is a 1,2,8 or 9. > Something like the following: > > IIf(Left([possib...

Receiving 2 of every message
I recently paid for a hotmail account so I could have larger storage and not get cancelled for any reasons such as not checking it often enough. I followed the instructions and put my service on Outlook Express. Now I'm receiving 2 of every message. What's up? Can I fix this? Thanks Darla ...

Help with RANK
Hi I need to rank 100+ numbers but I can't get the formula right. All th numbers are in one column, but not all the rows e.g. I need to Ran G1:G11 and G13:G25 and G32:G40 etc. How can you put in more than on reference? The cells G12,G26:G31 etc have numbers in them that I don' want ranked RANK(number,ref,order -- Message posted from http://www.ExcelForum.com =RANK(G1,MyList) where mylist is a selection of ranges defined with a single name, eg select all your ranges and do Insert / Name / Define, then call it MyList. Now use it in the rank formula and then copy the formula ...

HELP! Outlook Keeps Receiving Same E-Mail Messages
Hello: I keep getting the same 6 e-mail messages. This is after calling Norton and Comcast re receiving the same 3 e-mail messages (538 of them since midnight Dec 3!). Of course, it was not their problem, so it must be Outlook. Any thoughts. It sounds like you have an email message with a large attachment that is bogging down your account. What happens with the email is once you have connected to your ISP and clicked on the send/receive button if the connection is lost it will start over again until it can pull all of your messages in 1 sweep. You will need to log on to your accou...

Dialog getting hidden under HELP file
HI all, In my application I have a dialog & I launch HELP file from that dialog using F1 key. After that If I move the help file to one corner so that a part of the dialog is visible & click on the dialog & move it,it is moving,but when it comes over the HELP file,it is not overlapping but getting hidden under that. can anybody tell me what should I do to make it overlap the help file or give me a link that can help. Thanks in advance. Yes, that's how it is supposed to work. Help is a completely separate program, so its relationship to windows in ...

Re: Could someone please help me with formulas
sorry typo http://www.eaglepi.com/formula/example.xls "No" <no@isp.com> wrote in message news:... > I created a workbook and tried to explain the best I could how everything > should be. you can download the workbook at, > http://www.eaglepi.com/formlua/example.xls > > I really appreciate everyones help on this..... > > > "CLR" <croberts@tampabay.rr.com> wrote in message > news:%235IxtFEHFHA.2936@TK2MSFTNGP15.phx.gbl... > > Maybe in cell J2 you could put the formula =H2+I2, which would give you > the > > sum of the C...

HELP! Record Macro in TOOLS > MACRO is gone!
I was in Customize function trying to enable the Stop Recording toolbar and now in TOOLS > MACRO the Record Macro option is gone. I'm working on a project and I need this back. Can someone help? I'm using Excel 2003. Thanks, Joe M. Try this: In the customize window > click the Options tab > push the reset toolbars & menus button. Exit excel and re-load it Micky "Joe M." wrote: > I was in Customize function trying to enable the Stop Recording toolbar and > now in TOOLS > MACRO the Record Macro option is gone. I'm working on a ...

Simple question about text within a cell
I can't seem to find the option that prevents text from covering the adjacent cell. For example if I type the folling in cell A1: All I want for Christmas is my two front teeth. Obviously that will overflow over the cell B1 (if there is no data in B1). I don't want to resize my column, I only want the cell to show as much text in A1 as possible without covering cell B1. I believe I've seen the option to do what I'm looking for but I can't seem to find it and I can't figure out how to look it up in the HELP file. Thanks in advance. Rick My simple solution ha...