Posts by adilucb

    Hello, I NEED HELP SORTING COLUMNS IN A SPREADSHEET USING A POULLDOWN MENU. I want to be able to use the pulldown to sort in ascending order each of the columns I have in the excel file. Basically instead of manually having to rank the data in the columns I want to be able to just use my pulldow, please help me complete this task.


    The file Is attached, it has some code already but the SORT COLUMN PULLDOWN doesnt seem to work right now.
    The data in the sample file attached is random, i will go back and fill in th actual numbers later.
    Thank you very much.

    Re: Selecting All days(dates) in this week and Next


    :viking: This is a very simple question, but its one I cant seem to figure out. All I need to do is fidn the code that will allow me to move up, down, etc from a cell without selecting specific cells to move to.


    Right now If I want to move right (Im in Cell A1), I have to put in the follwing code: Range("A2").Select
    ISNT THERE A WAY I CAN MOVE TO RIGHT, UP, DOWN ETC WITHOUT SPECIFYING A CERTAIN CELL?


    Thanks:chase: :chase:

    Re: Moving (Up, Down, etc.) to another cell, without clearly selecting a specific cell


    :loo:
    This is a very simple question, but its one I cant seem to figure out. All I need to do is fidn the code that will allow me to move up, down, etc from a cell without selecting specific cells to move to.


    Right now If I want to move right (Im in Cell A1), I have to put in the follwing code: Range("A2").Select
    ISNT THERE A WAY I CAN MOVE TO RIGHT, UP, DOWN ETC WITHOUT SPECIFYING A CERTAIN CELL?


    Thanks :ole:

    Re: Moving (Up, Down, etc.) to another cell, without clearly selecting a specific cell


    Range("A65536").End(xldown).Select


    This script will take me to the last cell, thats NOT what I want to do. I want to be able to step down to the next row without telling the macro to go to A2 for example.


    Because I am looping the script if i tell it to go down it will select a specific cell and then always go to that cell, that means my data will be pasted over itself repeatedly. PLEASE HELP, IF I AM STILL UNCLEAR LET ME KNOW.

    Re: Moving (Up, Down, etc.) to another cell, without clearly selecting a specific cell


    Sure I have added my code below. Much of the code was created using the macro recording option, so pelase excuse the amatuer level of the coding.


    READ BEFORE CODE FOR CLARITY: The macro below copies data from sheet one which containt data organized by dates in Column A, the copied data is taken in 2 week intervals, so the week of the date selected and the following week are copied and taken to sheet2 for pasting. ONE OF THE PROBLEMS I AN HAVING: if I select a date which as an incomplete selected week the macro doesnt colec the data, I need to fix it so that if i select a date from the firt 5 dates for example, the macro will still collect data for as much of the week as is available.


    SECOND PROBLEM:
    Everytime I paste new data into the Sheet2, I have to create a new line over which I overlap newly pasted info so that all the data isnt just overwrite itself.


    Code:



    Sub Two_week_period_dataselection()


    ' Local Variables
    Dim dteEnd As Date
    Dim dteStart As Date
    Dim intRowCount As Integer

    ' Verify selection contains a valid date
    If Not IsDate(Selection.Range("A1")) Then Exit Sub

    ' Set date selection range
    dteStart = DateValue(DateAdd("d", -Weekday(Selection.Range("A1")) + 1, Selection.Range("A1")))
    dteEnd = DateAdd("d", 13, dteStart)

    ' Find size of data and select
    intRowCount = 0
    Do While Selection.Range("A1").Offset(intRowCount, 0) >= dteStart
    intRowCount = intRowCount - 1
    Loop

    Selection.Range("A1").Offset(intRowCount + 1, 0).Select
    intRowCount = 1
    Do While Selection.Range("A1").Offset(intRowCount + 1, 0) <= dteEnd
    intRowCount = intRowCount + 1
    Loop
    Range(Selection, Selection.Range("A1").Offset(intRowCount, 0)).Select

    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy


    Sheets("Sheet2").Select
    ActiveCell.Activate
    ActiveSheet.Paste

    'Creating extra highlighted line, indicating end of 2 week interval
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Selection.Insert Shift:=xlDown

    'highlighting of line
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    'Now I am clearingt he contents of the extra copied line, so that I can insert the next set of data which will overlap over the deleted row
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.ClearContents
    Selection.End(xlToLeft).Select
    Sheets("Sheet1").Select

    End Sub

    Re: Moving (Up, Down, etc.) to another cell, without clearly selecting a specific cell


    So I am really just trying to move down one cell, I have a macro written up which copies nad pastes data from one sheet to another, in order to have the macro paste the data next to and not over each the previous set of data I want to be able to move down a cell from my Activecell without specifying exactly which cell to go to.


    If i tell it exactly which cell to go to everytime i run the macro it will paste over the previous information.

    This is a very simple question, but its one I cant seem to figure out. All I need to do is fidn the code that will allow me to move up, down, etc from a cell without selecting specific cells to move to.


    Right now If I want to move right (Im in Cell A1), I have to put in the follwing code: Range("A2").Select
    ISNT THERE A WAY I CAN MOVE TO RIGHT, UP, DOWN ETC WITHOUT SPECIFYING A CERTAIN CELL?


    Thanks

    Re: Selecting rows by date for 14 day periods


    I get an error right now when the macro tries to find the start of a week and the date is not give, example maybe the data doesnt go that far back, Is there a way I can program it to back back as many days as possible???


    so if its friday selected, then the macro goes back as many days as possible to collect that week, maybe in that week monday tuesday were off so macro collects weds thurs and fri.


    Also Can you adjust the macro so it will copy all the columns not jut row A and then paste this content in Sheet two, One set of dates after another ...
    Your help is much appreciated!

    Re: Selecting All days(dates) in this week and Next


    I get an error right now when the macro tries to find the start of a week and the date is not give, example maybe the data doesnt go that far back, Is there a way I can program it to back back as many days as possible???


    so if its friday selected, then the macro goes back as many days as possible to collect that week, maybe in that week monday tuesday were off so macro collects weds thurs and fri.


    Also Can you adjust the macro so it will copy all the columns not jut row A and then paste this content in Sheet two, One set of dates after another ...
    Your help is much appreciated!

    Re: Selecting rows by date for 14 day periods


    Private Sub CommandButton1_Click()

    ' Local Variables
    Dim dteEnd As Date
    Dim dteStart As Date
    Dim intRowCount As Integer

    ' Verify selection contains a valid date
    If Not IsDate(Selection.Range("A1")) Then Exit Sub

    ' Set date selection range
    dteStart = DateValue(DateAdd("d", -Weekday(Selection.Range("A1")) + 1, Selection.Range("A1")))
    dteEnd = DateAdd("d", 13, dteStart)

    ' Find size of data and select
    intRowCount = 0
    Do While Selection.Range("A1").Offset(intRowCount, 0) >= dteStart
    intRowCount = intRowCount - 1
    Loop
    Selection.Range("A1").Offset(intRowCount + 1, 0).Select
    intRowCount = 1
    Do While Selection.Range("A1").Offset(intRowCount + 1, 0) <= dteEnd
    intRowCount = intRowCount + 1
    Loop
    Range(Selection, Selection.Range("A1").Offset(intRowCount, 0)).Select
    End Sub



    That good seems to be working fine, THANKS!


    there are still a few lil things I need to figure out, I get an error right now when the macro tries to find the start of a week and the date is not give, example maybe the data doesnt go that far back, Is there a way I can program it to back back as many days as possible???


    so if its friday selected, then the macro goes back as many days as possible to collect that week, maybe in that week monday tuesday were off so macro collects weds thurs and fri.


    Also Can you adjust the macro so it will copy all the columns not jut row A and then paste this content in Sheet two, One set of dates after another ...
    Your help is much appreciated!

    Re: Selecting All days(dates) in this week and Next


    That good seems to be working fine, THANKS!


    there are still a few lil things I need to figure out, I get an error right now when the macro tries to find the start of a week and the date is not give, example maybe the data doesnt go that far back, Is there a way I can program it to back back as many days as possible???


    so if its friday selected, then the macro goes back as many days as possible to collect that week, maybe in that week monday tuesday were off so macro collects weds thurs and fri.


    Also Can you adjust the macro so it will copy all the columns not jut row A and then paste this content in Sheet two, One set of dates after another ...
    Your help is much appreciated!

    Re: Selecting rows by date for 14 day periods


    rbrhodes your script above didnt work, Also i have new type of problem I am facign its described above as well.
    All the help has been great thanks, but now I have a new kind of problem.
    I have an excel sheet which has a column A with dates, and toher column of data.
    I need to be able to copy the data for the week I am in depending on which Day I select and also copy the following week, the last code I was workign on would give me 14 days ahead from a given start date.


    What i need to create is a smart macro which recognizes which day of the week it is then goes back a few days to include that intial entire week and then moves forward to include the following week.


    So lets say I start by clicking on a date which is a Thursday, i need the macro to select all the days behind thursday (monday, tues, weds & STOP AT SATURAY), then i need it to look forward to teh next week and select all days for the following week Monday Through Friday.


    Example)
    If I select 7/8/05 which is a Friday, I want the macro to go back a few dates all the way to begenning of week at Tuesday 7/05/05. Then I want it to also look forward and copy the days in the following week which are tues 7/21 through Fri 7/15


    I know this sounds complicated, thats why I cam to the experts, any thoughts guys?

    All the help has been great thanks, but now I have a new kind of problem.
    I have an excel sheet which has a column A with dates, and toher column of data.
    I need to be able to copy the data for the week I am in depending on which Day I select and also copy the following week, the last code I was workign on would give me 14 days ahead from a given start date.


    What i need to create is a smart macro which recognizes which day of the week it is then goes back a few days to include that intial entire week and then moves forward to include the following week.


    So lets say I start by clicking on a date which is a Thursday, i need the macro to select all the days behind thursday (monday, tues, weds & STOP AT SATURAY), then i need it to look forward to teh next week and select all days for the following week Monday Through Friday.


    Example)
    If I select 7/8/05 which is a Friday, I want the macro to go back a few dates all the way to begenning of week at Tuesday 7/05/05. Then I want it to also look forward and copy the days in the following week which are tues 7/21 through Fri 7/15


    I know this sounds complicated, thats why I cam to the experts, any thoughts guys?

    Re: Selecting rows by date for 14 day periods


    Ive been working on the code, and all your help has been great thanks, but now I have a new kind of problem.


    HELP NEW PROBLEM . . .
    I realized I need to be able to copy the data for the week I select and the following week, the last code I was workign on would give me 14 days no matter what the start date.


    What i need to create is a smart macro which recognizes which day of the week it is then goes back a few days to include that intial entire week and then moves forward to include the following week.


    So lets say I start by click on a date which is a Thursday, i need the macro to select all the days behind thursday (monday, tues, weds & STOP AT SATURAY), then i need it to look forward to teh next week and select all days for the following week Monday Through Friday.


    I know this sounds complicated, thats why I cam to the experts, any thoughts guys?

    Re: Selecting rows by date for 14 day periods


    I got a hold of some script which will convert the date nad time to just a date, now I just have to work on fitting it into the macro and I should be set.


    Dim myDate, ConvertDate As Date


    myDate = Sheets("sheet1").Range("A1:A" & end_row)
    ConvertDate = Month(myDate) & "/" & Day(myDate) & "/" & Year(myDate)

    Re: Selecting rows by date for 14 day periods


    Thanks it seems to be working great, except the Start date is being matched to the end date based on the date (1/01/05) and the Time, I want to only use the date to signify the end date. How can I change this so it works even is the time is different but the date is the same?

    Re: Selecting rows by date for 14 day periods


    I have attached a workbook which contains data which is similar to the data I will be working with later.


    As can be seen Column A conatins all the dates, What i want to do is select any cell in Column A and be able to copy all the rows down from the Selected Date to 2 weeks forward (14 days ahead). I want to copy all the data in between and paste it into a new sheet.


    I want to copy from Start Date to End date, 14 day period. Whatever cell I click on I want the macro to copy all the data between Start and End. Sometimes End date wont be in the data, there are gaps for weekend and holidays then I want the macro to check End Date -1, go back one day and check, if there is still no date go back another day until a end date can be set. Then Copy from Start Date to end Date and past in a new sheet.

    Re: Dates: Selecting rows based on 2 week intervals


    I have attached a workbook which contains data which is similar to the data I will be working with later.


    As can be seen Column A conatins all the dates, What i want to do is select any cell in Column A and be able to copy all the rows down from the Selected Date to 2 weeks forward (14 days ahead). I want to copy all the data in between and paste it into a new sheet.


    I want to copy from Start Date to End date, 14 day period. Whatever cell I click on I want the macro to copy all the data between Start and End. Sometimes End date wont be in the data, there are gaps for weekend and holidays then I want the macro to check End Date -1, go back one day and check, if there is still no date go back another day until a end date can be set. Then Copy from Start Date to end Date and past in a new sheet.

    Selecting Rows Based On Date Within 14 Day Period


    SELECTING ROWS BASED ON DATE WITHIN 14 DAY PERIOD
    Selecting Rows Based On Date Within 14 Day Period


    --------------------------------------------------------------------------------


    I need some help
    SELECTING ROWS BASED ON DATE WITHIN 14 DAY PERIOD
    I have data from a calendar in my excel spreadsheet, I want to be able to select any date located in the first Column A, and then run a macro which will find the date 2 weeks ahead, copy the data in between and paste in a new sheet or new file.


    The problem is the date 2 weeks ahead must be a weekday, becasue weekend and holiday info is missing. If the date 14 days ahead is missing I want the macro to go to the previous day and try to find it, if it is also missing then go back 1 more day...until it find a date which is actually in the calendar data.