LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default difficulty with percentage from worksheet as seen by VBA

Cells E3, I3, J3, and K3 are ideally formatted as percent for ease of
interpretation by users, however this creates a difficulty with the value of
K3 seen as "1" in the VBA code.

Even though for example by comparrisson the value of E3 on the spread sheet
is 62% and is seen in the VBA coce as 0.62 I can not see what is out of
order.

I have tried refromatting the cell K3, using a different cell, but no matter
what I have tried I continue to see the vlaue of cell K3 (55%) from the
spreadsheet being seen as "1" within the VBA code, which of course stops one
section of the code from activating. Any help would be appreciated, See code
below!

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

Dim ThsWk, LstWk, Avg, Trgt, Lb, Ub, Ooc As Long

'get variable values
ThsWk = Worksheets("Sheet1").Range("E3").Value
Lb = Worksheets("Sheet1").Range("I3").Value
Ub = Worksheets("Sheet1").Range("J3").Value
Ooc = Worksheets("Sheet1").Range("K3").Value

' test variable cases

If ThsWk Ooc Then
With Worksheets("Sheet1").Range("C3").Value
Worksheets("Sheet1").Range("C3").Font.Name = "arial"
Worksheets("Sheet1").Range("C3").Value = "©"
Worksheets("Sheet1").Range("C3").Interior.ColorInd ex = 3
End With
End If


If ThsWk Ub And ThsWk < Ooc Then
With Worksheets("Sheet1").Range("C3").Value = "what?"
Worksheets("Sheet1").Range("C3").Value = ""
Worksheets("Sheet1").Range("C3").Font.Name = "arial"
Worksheets("Sheet1").Range("C3").Interior.ColorInd ex = 3
End With
End If

If ThsWk < Ub And ThsWk Lb Then
With Worksheets("Sheet1").Range("C3")
Worksheets("Sheet1").Range("C3").Value = ""
Worksheets("Sheet1").Range("C3").Font.Name = "arial"
Worksheets("Sheet1").Range("C3").Interior.ColorInd ex = 6
End With
End If

If ThsWk < Lb Then
With Worksheets("Sheet1").Range("C3").Value
Worksheets("Sheet1").Range("C3").Value = ""
Worksheets("Sheet1").Range("C3").Font.Name = "arial"
Worksheets("Sheet1").Range("C3").Interior.ColorInd ex = 4
End With
End If

End Sub
--
hippy
 
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
adding a percentage for COLA to Payroll worksheet luvkisn Excel Worksheet Functions 2 July 13th 09 11:33 PM
Difficulty with IMPOWER() Worksheet Function monir Excel Worksheet Functions 9 June 8th 08 06:20 AM
How do I apply icon sets to percentage values in Excel worksheet? Still Learning? Excel Worksheet Functions 1 April 24th 08 12:14 AM
how to copy same percentage to complete worksheet steelbird Excel Worksheet Functions 1 October 8th 06 03:55 PM
Increase excel worksheet vlaues by a percentage Nigel C Excel Worksheet Functions 5 April 27th 06 07:48 AM


All times are GMT +1. The time now is 06:53 AM.

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"