Consulting

Results 1 to 3 of 3

Thread: VBA code below

  1. #1
    VBAX Newbie
    Joined
    Feb 2011
    Posts
    5
    Location

    VBA code below

    Hi Hag've found is and hope you will help me
    My problem is that I behooves the VBA code below:
    In an excel sheet I have in column C with the following dates in an irregular sequence can see the example below:
    "C2" date "2011-01-03"
    "C3: C8" is in. Celer
    "C9" date "2011-01-05"
    "C10: C15" is in. Celer
    "C16" date "2011-01-06"
    "C17: C18" is in. Celer
    "C19" date "2011-01-10"
    "C20: C23" is in. Celer
    "C24" date "2011-01-05"
    "C25: C30" is in. Celer
    "C26" date "END"

    Task:
    First found dates in column "C" should be copied to any compromising cell to the next date found:
    Example:
    "C2" date "2011-01-03" will be copied to the "C3: C8"
    Later found date "C9" date "2011-01-05" and it will be copied to the underlying compromising cell "C10: C15"
    And so on until one is found in column "C" text "END" This will stop functioning.

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    Ride the wind to the sun
    Posts
    2,598
    if you want to fill in the blank cells in range C2:C30 with the above cell's value until the cell value is "END" then try:

    [VBA]
    Option Explicit

    Sub fill_blank_cells()

    Dim Rng As Range
    Dim cll As Range

    On Error Resume Next

    Set Rng = Range("C2:C30").Cells.SpecialCells(xlCellTypeBlanks)

    Do
    Rng.FormulaR1C1 = "=R[-1]C"
    Loop Until cll.Value = "END"

    For Each cll In Rng
    cll.Value = cll.Value
    Next cll

    End Sub

    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Newbie
    Joined
    Feb 2011
    Posts
    5
    Location

    Thank you very much mancubus

    It works as I have in mind.
    Thank you very much mancubus

Posting Permissions

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