+ Reply to Thread
Results 1 to 9 of 9

Show %age in cell using VBA

  1. #1
    Registered User
    Join Date
    05-07-2014
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Unhappy Show %age in cell using VBA

    Hi Forum,
    I am using VBA to form a budget and have struck a problem.
    The problem is I cannot get the cells (Columns 10 and 11) show a %age instead of text or number, please see code below.
    Any help on this would be greatly appreciated.

    Private Sub BtnOk_Click()
    'Find next row on the data sheet
    NextRow = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp).Row + 1

    'Write the values from this form to that row
    With Worksheets("Data")
    .Cells(NextRow, 1).Value = Me.TbId
    .Cells(NextRow, 2).Value = Me.TbName
    .Cells(NextRow, 3).Value = Me.LbDept.Value
    .Cells(NextRow, 4).Value = Me.TbRate
    .Cells(NextRow, 5).Value = Me.TbHrs
    .Cells(NextRow, 6).Value = Me.TbDays
    If Me.OptBtnYes = True Then
    .Cells(NextRow, 7) = "Yes"
    Else
    .Cells(NextRow, 7) = "No"
    End If
    .Cells(NextRow, 10).Value = Me.TbSupN
    .Cells(NextRow, 11).Value = Me.TbSupC
    If Me.OptBtnHousY = True Then
    .Cells(NextRow, 8).Value = 5000#
    Else
    .Cells(NextRow, 8).Value = "N/A"
    End If

    End With

    'Unload the Form
    Unload Me
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Show %age in cell using VBA

    Example workbook? Make life easier please

  3. #3
    Registered User
    Join Date
    05-07-2014
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Show %age in cell using VBA

    Hi Philb1,
    Sorry, so new to this.
    Cannot see any "attachment" icon.
    Have sent a request to the webmaster to find out how to insert a workbook or file here.
    will get back to you when I know how to insert the workbook.
    Thanks for your patience in this matter.
    Jdin54

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Show %age in cell using VBA

    ... find out how to insert a workbook or file here.
    Everything you need to know is in the forum rules.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Show %age in cell using VBA

    Quote Originally Posted by shg View Post
    Everything you need to know is in the forum rules.
    Yes that is true, but in my case I haven't been able to upload an attachment for quite a while. I've given up & use a link to dropbox.

  6. #6
    Registered User
    Join Date
    05-07-2014
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Show %age in cell using VBA

    Hi Philb1

    http://www.excelforum.com/attachment...1&d=1456785793
    Please let me know if ok.
    Thanks again.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Show %age in cell using VBA

    The textboxes are entering text values into the sheet cells. Convert the values to long & divide by 100 like this
    Please Login or Register  to view this content.
    Cheers

  8. #8
    Registered User
    Join Date
    05-07-2014
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Show %age in cell using VBA

    Thanks Philb1,
    That has worked in that the %ages are showing, but only as a full %age. I tried to get the %age to 2 decimal places by changing the CLng to CInt but that didn't work.
    Can you suggest a fix for this. I really do need the result of the super to show as for example 9.50 or 3.55.
    Regards

  9. #9
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Show %age in cell using VBA

    Try this

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 09-06-2014, 10:50 AM
  2. [SOLVED] One TextBox Show Column and the other show Cell address Solved by : ragulduy
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-26-2014, 05:17 AM
  3. Replies: 2
    Last Post: 02-24-2014, 08:20 PM
  4. Replies: 12
    Last Post: 05-10-2013, 11:12 AM
  5. Replies: 2
    Last Post: 02-18-2012, 05:52 PM
  6. Replies: 4
    Last Post: 11-17-2008, 12:15 PM
  7. Replies: 1
    Last Post: 04-11-2008, 02:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1