Results 1 to 10 of 11

Thread: Excel Macro to populate the values in the required cells

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    5
    Rep Power
    0
    Apologies for the confusion.No Rick, the logic that you have provided is basically generating a sequence set of values with in the same sheet but i need other way around which means complete (P) sheet should have same set of value like ("1 Minutes -4431 01/01/2013")
    and next occurence of (P) should have incremental value like (" 2 Minutes -4431 01/01/2013).

    For example:
    FreeP sheet : " 1 Minutes -4431 01/01/2013".
    FreeS Sheet : " 0 Minutes -4431 01/01/2013"
    CostP Sheet : "" 2 Minutes -4431 01/01/2013"
    CostS Sheet : " 0 Minutes -4431 01/01/2013"

    I hope this clears the confusion.

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by pbabu View Post
    Apologies for the confusion.No Rick, the logic that you have provided is basically generating a sequence set of values with in the same sheet but i need other way around which means complete (P) sheet should have same set of value like ("1 Minutes -4431 01/01/2013")
    and next occurence of (P) should have incremental value like (" 2 Minutes -4431 01/01/2013).

    For example:
    FreeP sheet : " 1 Minutes -4431 01/01/2013".
    FreeS Sheet : " 0 Minutes -4431 01/01/2013"
    CostP Sheet : "" 2 Minutes -4431 01/01/2013"
    CostS Sheet : " 0 Minutes -4431 01/01/2013"
    Okay then, how about this macro, does it do what you want?

    Code:
    Sub ExcelFoxAndRick()
      Dim Index As Long, Wks As Worksheet, Rng As Range
      For Each Wks In ThisWorkbook.Worksheets
        Set Rng = Wks.Range("G9:J" & Wks.Cells(Rows.Count, "A").End(xlUp).Row)
        If Wks.Name Like "*[PS]" Then Rng = Array(Abs(Wks.Name Like "*P"), "Minutes", -4431, #1/1/2013#)
        If Right(Wks.Name, 1) = "P" Then
          Index = Index + 1
          Rng.Columns(1) = Index
        End If
      Next
    End Sub

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    5
    Rep Power
    0
    it works perfect. Thank you very much rick !

Similar Threads

  1. populate default values in cell of a csv file
    By dhivya.enjoy in forum Excel Help
    Replies: 2
    Last Post: 10-23-2013, 12:59 PM
  2. Replies: 12
    Last Post: 07-26-2013, 07:39 AM
  3. VBA Program to Compare 4 Columns in Excel (Required)
    By vijaysram in forum Excel Help
    Replies: 11
    Last Post: 06-26-2013, 10:53 AM
  4. Unmerge Cells and Fill with Duplicate Values
    By princ_wns in forum Excel Help
    Replies: 3
    Last Post: 10-09-2012, 07:36 AM

Posting Permissions

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