Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Vlookup, hlookup, match ???

I have a workbook with the two sheets.

Sheet 1 contains in Column A various categories and the next 31 column
headings represent a date (day for each day of the month) the dollar
amount associated with each category by day.

Sheet 2 contains in column A some of the various categories from Sheet
1 and in Sheet2!B1, I would like to insert the date and it would
automatically populate the corresponding values from Sheet 1 for each
category listed on Sheet 2 for the filled in date.

Not sure the best way to do this.....

Thx!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vlookup, hlookup, match ???

Belwo si code that may work. I don't know if the date in Sheet one in row 1
is a date or just the numbers 1 to 31. I assumed the row contains actual
dates. if itis just numbers the make the following change
from:
If .Cells(1, columncount).Value = _
Target Then
to:
If .Cells(1, columncount).Value = _
day(Target) Then

The worksheet change gets placed in the VBA sheet page, not a module.
To add, go to the second sheet of workbokk and right click tab at botom of
sheet (normally sheet2). the select view code. Copy code and insert in VBA
page.



Sub worksheet_change(ByVal Target As Range)

If Target.Column = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then

.Range(.Cells(2, columncount), _
.Cells(11, columncount)).Copy

Range("B" & Target.Row).Select
Selection.PasteSpecial _
Transpose:=True
End If
Next columncount
End With

End If

End Sub


"samdev" wrote:

I have a workbook with the two sheets.

Sheet 1 contains in Column A various categories and the next 31 column
headings represent a date (day for each day of the month) the dollar
amount associated with each category by day.

Sheet 2 contains in column A some of the various categories from Sheet
1 and in Sheet2!B1, I would like to insert the date and it would
automatically populate the corresponding values from Sheet 1 for each
category listed on Sheet 2 for the filled in date.

Not sure the best way to do this.....

Thx!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Vlookup, hlookup, match ???

On Sep 1, 6:36 pm, Joel wrote:
Belwo si code that may work. I don't know if the date in Sheet one in row 1
is a date or just the numbers 1 to 31. I assumed the row contains actual
dates. if itis just numbers the make the following change
from:
If .Cells(1, columncount).Value = _
Target Then
to:
If .Cells(1, columncount).Value = _
day(Target) Then

The worksheet change gets placed in the VBA sheet page, not a module.
To add, go to the second sheet of workbokk and right click tab at botom of
sheet (normally sheet2). the select view code. Copy code and insert in VBA
page.

Sub worksheet_change(ByVal Target As Range)

If Target.Column = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then

.Range(.Cells(2, columncount), _
.Cells(11, columncount)).Copy

Range("B" & Target.Row).Select
Selection.PasteSpecial _
Transpose:=True
End If
Next columncount
End With

End If

End Sub



"samdev" wrote:
I have a workbook with the two sheets.


Sheet 1 contains in Column A various categories and the next 31 column
headings represent a date (day for each day of the month) the dollar
amount associated with each category by day.


Sheet 2 contains in column A some of the various categories from Sheet
1 and in Sheet2!B1, I would like to insert the date and it would
automatically populate the corresponding values from Sheet 1 for each
category listed on Sheet 2 for the filled in date.


Not sure the best way to do this.....


Thx!!- Hide quoted text -


- Show quoted text -


Did this and nothing happened - I'm I missing something???

Thx,

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vlookup, hlookup, match ???

I don't know how well you know VBA on the best way to proceeed. I tested the
code by put the dates from 1/1/07 to 1/31/07 on worksheet SHEET1 in cells
B1:AG1. I also put the numbers 1 to 10 in cells K2 to K11 which was under
the data 1/10/07

I then went to the worksheet page where on put the code (I used sheet2). and
in Column A I typed the date 1/10/07. The numbers 1 to 10 appeared on sheet2
next to the the date 1/10/07.

Get this working. then modify the code to copy the cells you needed copied.
"samdev" wrote:

On Sep 1, 6:36 pm, Joel wrote:
Belwo si code that may work. I don't know if the date in Sheet one in row 1
is a date or just the numbers 1 to 31. I assumed the row contains actual
dates. if itis just numbers the make the following change
from:
If .Cells(1, columncount).Value = _
Target Then
to:
If .Cells(1, columncount).Value = _
day(Target) Then

The worksheet change gets placed in the VBA sheet page, not a module.
To add, go to the second sheet of workbokk and right click tab at botom of
sheet (normally sheet2). the select view code. Copy code and insert in VBA
page.

Sub worksheet_change(ByVal Target As Range)

If Target.Column = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then

.Range(.Cells(2, columncount), _
.Cells(11, columncount)).Copy

Range("B" & Target.Row).Select
Selection.PasteSpecial _
Transpose:=True
End If
Next columncount
End With

End If

End Sub



"samdev" wrote:
I have a workbook with the two sheets.


Sheet 1 contains in Column A various categories and the next 31 column
headings represent a date (day for each day of the month) the dollar
amount associated with each category by day.


Sheet 2 contains in column A some of the various categories from Sheet
1 and in Sheet2!B1, I would like to insert the date and it would
automatically populate the corresponding values from Sheet 1 for each
category listed on Sheet 2 for the filled in date.


Not sure the best way to do this.....


Thx!!- Hide quoted text -


- Show quoted text -


Did this and nothing happened - I'm I missing something???

Thx,


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Vlookup, hlookup, match ???

On Sep 2, 6:16 pm, Joel wrote:
I don't know how well you know VBA on the best way to proceeed. I tested the
code by put the dates from 1/1/07 to 1/31/07 on worksheet SHEET1 in cells
B1:AG1. I also put the numbers 1 to 10 in cells K2 to K11 which was under
the data 1/10/07

I then went to the worksheet page where on put the code (I used sheet2). and
in Column A I typed the date 1/10/07. The numbers 1 to 10 appeared on sheet2
next to the the date 1/10/07.

Get this working. then modify the code to copy the cells you needed copied.



"samdev" wrote:
On Sep 1, 6:36 pm, Joel wrote:
Belwo si code that may work. I don't know if the date in Sheet one in row 1
is a date or just the numbers 1 to 31. I assumed the row contains actual
dates. if itis just numbers the make the following change
from:
If .Cells(1, columncount).Value = _
Target Then
to:
If .Cells(1, columncount).Value = _
day(Target) Then


The worksheet change gets placed in the VBA sheet page, not a module.
To add, go to the second sheet of workbokk and right click tab at botom of
sheet (normally sheet2). the select view code. Copy code and insert in VBA
page.


Sub worksheet_change(ByVal Target As Range)


If Target.Column = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then


.Range(.Cells(2, columncount), _
.Cells(11, columncount)).Copy


Range("B" & Target.Row).Select
Selection.PasteSpecial _
Transpose:=True
End If
Next columncount
End With


End If


End Sub


"samdev" wrote:
I have a workbook with the two sheets.


Sheet 1 contains in Column A various categories and the next 31 column
headings represent a date (day for each day of the month) the dollar
amount associated with each category by day.


Sheet 2 contains in column A some of the various categories from Sheet
1 and in Sheet2!B1, I would like to insert the date and it would
automatically populate the corresponding values from Sheet 1 for each
category listed on Sheet 2 for the filled in date.


Not sure the best way to do this.....


Thx!!- Hide quoted text -


- Show quoted text -


Did this and nothing happened - I'm I missing something???


Thx,- Hide quoted text -


- Show quoted text -


Got this to work - but I only want certain numbers copied to
sheet2....For example; in Column A sheet 1 - I have categories and not
all categories need to be copied to Sheet2 - for example, in your
scenario - I may only need K2, K6, K10 on sheet2. and these values on
sheet2 need to be below the date on Sheet2 not to the right.

I'm new to VB so I do appreciate your help and your patience.

Thx,



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vlookup, hlookup, match ???

I changed the first if statement
from
If Target.Column = 1 Then
to
If Target.Row = 1 Then

Now if you enter date on first row (used to be first column) the data will
be copied. Gave some examples of copying individual cells from one sheet to
the 2nd sheet.

Sub worksheet_change(ByVal Target As Range)

If Target.Row = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then

Cells(4, Target.Column) = _
.Cells(5, columncount)

Cells(7, Target.Column) = _
.Cells(6, columncount)

Cells(9, Target.Column) = _
.Cells(7, columncount)

End If
Next columncount
End With

End If

End Sub
"samdev" wrote:

On Sep 2, 6:16 pm, Joel wrote:
I don't know how well you know VBA on the best way to proceeed. I tested the
code by put the dates from 1/1/07 to 1/31/07 on worksheet SHEET1 in cells
B1:AG1. I also put the numbers 1 to 10 in cells K2 to K11 which was under
the data 1/10/07

I then went to the worksheet page where on put the code (I used sheet2). and
in Column A I typed the date 1/10/07. The numbers 1 to 10 appeared on sheet2
next to the the date 1/10/07.

Get this working. then modify the code to copy the cells you needed copied.



"samdev" wrote:
On Sep 1, 6:36 pm, Joel wrote:
Belwo si code that may work. I don't know if the date in Sheet one in row 1
is a date or just the numbers 1 to 31. I assumed the row contains actual
dates. if itis just numbers the make the following change
from:
If .Cells(1, columncount).Value = _
Target Then
to:
If .Cells(1, columncount).Value = _
day(Target) Then


The worksheet change gets placed in the VBA sheet page, not a module.
To add, go to the second sheet of workbokk and right click tab at botom of
sheet (normally sheet2). the select view code. Copy code and insert in VBA
page.


Sub worksheet_change(ByVal Target As Range)


If Target.Column = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then


.Range(.Cells(2, columncount), _
.Cells(11, columncount)).Copy


Range("B" & Target.Row).Select
Selection.PasteSpecial _
Transpose:=True
End If
Next columncount
End With


End If


End Sub


"samdev" wrote:
I have a workbook with the two sheets.


Sheet 1 contains in Column A various categories and the next 31 column
headings represent a date (day for each day of the month) the dollar
amount associated with each category by day.


Sheet 2 contains in column A some of the various categories from Sheet
1 and in Sheet2!B1, I would like to insert the date and it would
automatically populate the corresponding values from Sheet 1 for each
category listed on Sheet 2 for the filled in date.


Not sure the best way to do this.....


Thx!!- Hide quoted text -


- Show quoted text -


Did this and nothing happened - I'm I missing something???


Thx,- Hide quoted text -


- Show quoted text -


Got this to work - but I only want certain numbers copied to
sheet2....For example; in Column A sheet 1 - I have categories and not
all categories need to be copied to Sheet2 - for example, in your
scenario - I may only need K2, K6, K10 on sheet2. and these values on
sheet2 need to be below the date on Sheet2 not to the right.

I'm new to VB so I do appreciate your help and your patience.

Thx,


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Vlookup, hlookup, match ???

On Sep 3, 6:44 am, Joel wrote:
I changed the first if statement
from
If Target.Column = 1 Then
to
If Target.Row = 1 Then

Now if you enter date on first row (used to be first column) the data will
be copied. Gave some examples of copying individual cells from one sheet to
the 2nd sheet.

Sub worksheet_change(ByVal Target As Range)

If Target.Row = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then

Cells(4, Target.Column) = _
.Cells(5, columncount)

Cells(7, Target.Column) = _
.Cells(6, columncount)

Cells(9, Target.Column) = _
.Cells(7, columncount)

End If
Next columncount
End With

End If

End Sub



"samdev" wrote:
On Sep 2, 6:16 pm, Joel wrote:
I don't know how well you know VBA on the best way to proceeed. I tested the
code by put the dates from 1/1/07 to 1/31/07 on worksheet SHEET1 in cells
B1:AG1. I also put the numbers 1 to 10 in cells K2 to K11 which was under
the data 1/10/07


I then went to the worksheet page where on put the code (I used sheet2). and
in Column A I typed the date 1/10/07. The numbers 1 to 10 appeared on sheet2
next to the the date 1/10/07.


Get this working. then modify the code to copy the cells you needed copied.


"samdev" wrote:
On Sep 1, 6:36 pm, Joel wrote:
Belwo si code that may work. I don't know if the date in Sheet one in row 1
is a date or just the numbers 1 to 31. I assumed the row contains actual
dates. if itis just numbers the make the following change
from:
If .Cells(1, columncount).Value = _
Target Then
to:
If .Cells(1, columncount).Value = _
day(Target) Then


The worksheet change gets placed in the VBA sheet page, not a module.
To add, go to the second sheet of workbokk and right click tab at botom of
sheet (normally sheet2). the select view code. Copy code and insert in VBA
page.


Sub worksheet_change(ByVal Target As Range)


If Target.Column = 1 Then
With Sheets("sheet1")
LastColumn = .Cells(1, Columns.Count). _
End(xlToLeft).Column
For columncount = 2 To LastColumn
If .Cells(1, columncount).Value = _
Target Then


.Range(.Cells(2, columncount), _
.Cells(11, columncount)).Copy


Range("B" & Target.Row).Select
Selection.PasteSpecial _
Transpose:=True
End If
Next columncount
End With


End If


End Sub


"samdev" wrote:
I have a workbook with the two sheets.


Sheet 1 contains in Column A various categories and the next 31 column
headings represent a date (day for each day of the month) the dollar
amount associated with each category by day.


Sheet 2 contains in column A some of the various categories from Sheet
1 and in Sheet2!B1, I would like to insert the date and it would
automatically populate the corresponding values from Sheet 1 for each
category listed on Sheet 2 for the filled in date.


Not sure the best way to do this.....


Thx!!- Hide quoted text -


- Show quoted text -


Did this and nothing happened - I'm I missing something???


Thx,- Hide quoted text -


- Show quoted text -


Got this to work - but I only want certain numbers copied to
sheet2....For example; in Column A sheet 1 - I have categories and not
all categories need to be copied to Sheet2 - for example, in your
scenario - I may only need K2, K6, K10 on sheet2. and these values on
sheet2 need to be below the date on Sheet2 not to the right.


I'm new to VB so I do appreciate your help and your patience.


Thx,- Hide quoted text -


- Show quoted text -


Thank you - works great - much appreciated!!!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Match/Vlookup/Hlookup ? Daniel Q. Excel Worksheet Functions 3 September 19th 08 05:08 AM
HLOOKUP or VLOOKUP or Index or Match or WHAT? MNProp Excel Discussion (Misc queries) 2 May 17th 07 09:55 PM
HLOOKUP, VLOOKUP, MATCH, INDEX - Help with the Right Solution! Michael Excel Discussion (Misc queries) 1 March 28th 07 03:40 PM
vlookup, sumproduct, hlookup, index match, not sure SteveC Excel Discussion (Misc queries) 5 February 15th 07 08:46 PM
VLookUp or HLookUp Plus Index - Match, I think??? Jay Excel Worksheet Functions 11 September 15th 06 07:26 AM


All times are GMT +1. The time now is 09:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"