Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

help w easy VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
xrbbaker - 15 Jun 2007 13:47 GMT
Hello,

I'm new to the VBA side of things.  I want to select a range of cells and
for each cell in that selection, divide it by the value that is in row1 of
the same column, and return that value to the cell.  (I'm converting a number
to a percent by dividing current number by total number, which is kept in row
1, same column.)  I have some of the code, but don't know how to represent
the value of row 1, same column.  Can someone please assist?  thanks - Russ

Sub ConvertHoursToPercent()
   Dim Cell As Range
   For Each Cell In Selection
       If IsNumeric(Cell.Value) Then Cell.Value =
   Next Cell
End Sub
Bob Phillips - 15 Jun 2007 14:19 GMT
Sub ConvertHoursToPercent()
   Dim Cell As Range
   For Each Cell In Selection
       If IsNumeric(Cell.Value) Then
           Cell.Value = Cell.Value / Cells(Cell.Row,1).Value
       End If
   Next Cell
End Sub

Signature

HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Hello,
>
[quoted text clipped - 14 lines]
>    Next Cell
> End Sub
xrbbaker - 15 Jun 2007 15:09 GMT
Thanks Bob.  I still struggle with this stuff.  I know what I want to do but
I can't figure out the whole object model relationship thing and browsing the
Object Model isn't helping me yet.  I'm sure that just comes with time.

thx

> Sub ConvertHoursToPercent()
>     Dim Cell As Range
[quoted text clipped - 23 lines]
> >    Next Cell
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.