obtain data of next 10 days

Hi all, i need your help again. Now, my problem is, i have two columns of data. one of the columns is 1 to 100 and another column is data corresponding to column 1, which is shown below, and a userform which has a combo box with values from 1 to 100.

data:
1 => d
2 => f
3 => t
4 =>s
5 => n
6 =>k
7 =>o
8 =>w
9 =>x
10 =>b
11 =>jo
12 =>yt
13 =>cv
14 =>ad
.
.
.


let say i have a combo box with values 1 to 100, when i choose one of the value in the combo box, i need a macro that can show me all the data of the following 10 days in another excel sheet. Can this be done
Thanks a lot!! :)


Answer this question

obtain data of next 10 days

  • Zados Maerc

    Hi! Thanks!! your code works GREAT!!! Thanks alot!!
    but i have another question: if i want to make the selection in a userform instead of in the excel work sheet, do i just need to change the intersect argument
    Thanks!!!

  • BhuttCrackSpackle

    Hi

    When you use a user form the spreadsheet does not change. You need to work with the forms events to set your macro to work. If you have a form with a listbox you could put your code in the ListBox change event which would then run your macro.

    Private Sub ListBox1_Change()
    ...Code goes here

    End Sub


  • rravech

    Hi

    If you put the selection in a userform you will need to move the code to the userform class module, so that it responds to changes on the userform rather than the worksheet. You can lose the check to see which cell changes as this is not relevant to the form


  • Tom Nash

    Hi Pippen

    Try the below: My data is in sheet1 a1:B100 . Cell G1 has my combo box in it. Macro is attanced to sheet1s change event so that changes to the combo box are picked up.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim x As Long
    If Intersect(Target, Sheet1.Range("G1")) Then
    x = Sheet1.Cells(1, 7).Value
    Range("A" & x & ":B" & x + 9).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets.Add
    ActiveSheet.Range("A1").Select
    ActiveSheet.Paste
    End If
    End Sub


  • jchau

    Hi, I still don't understand your meaning by moving the code to the user form. I tried but cannot get it done.
    i also tried the first column with date. it ended up tat the copy function doesn't copy the correct value, instead it copies the row number with the index of the date. is there any method to solve this problem
    Thanks. :)

    ADG wrote:

    Hi

    If you put the selection in a userform you will need to move the code to the userform class module, so that it responds to changes on the userform rather than the worksheet. You can lose the check to see which cell changes as this is not relevant to the form


  • obtain data of next 10 days