+ Reply to Thread
Results 1 to 1 of 1

Find Column Title instead of using Ranges

Hybrid View

  1. #1
    Registered User
    Join Date
    05-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Find Column Title instead of using Ranges

    I have a Excel sheet with 3 columns, Start date (Column Title: Start), End date (Column Title: End) and Price (Column Title: Price).
    My current macros is calculating the New Price (365 days) based on the Price given and the Start and End date. The current macros, I have inserted Column Ranges, but each time the the sheet will be different, so can someone help me to change this macros so that it work with multiple sheet where it finds the 3 different Column Titles first and then apply the formula and output New Price will be in the first blank column.

    Sub NewPrice()
    
    Dim TotalPr As Range
    Dim StDate As Double
    Dim EnDate As Double
    Dim NewPr As Double
    Dim Days As Integer
    Dim Length As Integer
    
    StDate = 0
    EnDate = 0
    
    Set TotalPr = Range("A1").End(xlToRight).Offset(0, 1)
    TotalPr = "New Price"
    Length = Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
    
    
    For j = 2 To Length
    
    StDate = Range("B" & j)
    EnDate = Range("C" & j)
    Days = (EnDate - StDate)
    NewPr = ((Range("D" & j) / Days) * 365)
    Range("E" & j).Value = Newpr
    
    Next j
    
    
    End Sub
    Last edited by xyang06; 07-01-2013 at 10:06 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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