Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default FORMULA OR VB

I AM HAVING TROUBLE TRYING TO FIGURE OUT WHICH FORMULA WOULD WORK BEST FOR
THE FOLLOWING OR IF I NEED TO HAVE VB TO DO THIS. I NEED TO PUT THE DATA FROM
COLUMN B IN THE SAME ROW IF I HAVE MATCHING DATA IN COLUMN A.

7400 1A
7400 2A
7400 3A
7401 1A
7401 2A

RESULT.

7400 1A,2A,3A
7401 1A,2A

OR IT COULD BE IN COLUMNS

7400 1A 2A 3A
7401 1A 2A

EITHER WAY THANKS TO ANYONE THAT CAN GIVE ME AN IDEA.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default FORMULA OR VB

On Mar 16, 5:09 pm, Tomkat743
wrote:
I AM HAVING TROUBLE TRYING TO FIGURE OUT WHICH FORMULA WOULD WORK BEST FOR
THE FOLLOWING OR IF I NEED TO HAVE VB TO DO THIS. I NEED TO PUT THE DATA FROM
COLUMN B IN THE SAME ROW IF I HAVE MATCHING DATA IN COLUMN A.

7400 1A
7400 2A
7400 3A
7401 1A
7401 2A

RESULT.

7400 1A,2A,3A
7401 1A,2A

OR IT COULD BE IN COLUMNS

7400 1A 2A 3A
7401 1A 2A

EITHER WAY THANKS TO ANYONE THAT CAN GIVE ME AN IDEA.


Please do not post in CAPS - it's hard to read.

This looks like a pivot table's output!

However, if you do wish to do it in VB to avoid the formatting and
references, etc, you could try this:
1) Get an array of all column A entries (7400 and 7401)
2) Print these entries in a different location
3) Look at each entry in column B, then check if it matches the
entries that you've moved somewhere else
4) If it does, write it into the first blank empty cell / concatenate
the existing text

that's it .. if you have any questions regarding the coding you can
post again here. It's always best to try it out first though!

Chris
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default FORMULA OR VB

This example assumes that the original data is on Sheet1 and the revised
format will be entered in Sheet2:

Sub newlist()
Set w1 = Sheets("Sheet1")
Set w2 = Sheets("Sheet2")
w2.Cells(1, 1).Value = w1.Cells(1, 1).Value
w2.Cells(1, 2).Value = w1.Cells(1, 2).Value
Ide = Cells(1, 1).Value
w1.Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 3
kk = 1
For i = 2 To n
If w1.Cells(i, 1).Value = Ide Then
w2.Cells(kk, k).Value = w1.Cells(i, 2).Value
k = k + 1
Else
kk = kk + 1
k = 3
Ide = w1.Cells(i, 1).Value
w2.Cells(kk, 1).Value = Ide
w2.Cells(kk, 2).Value = w1.Cells(i, 2).Value
End If
Next
End Sub

--
Gary''s Student - gsnu200773


"Tomkat743" wrote:

I AM HAVING TROUBLE TRYING TO FIGURE OUT WHICH FORMULA WOULD WORK BEST FOR
THE FOLLOWING OR IF I NEED TO HAVE VB TO DO THIS. I NEED TO PUT THE DATA FROM
COLUMN B IN THE SAME ROW IF I HAVE MATCHING DATA IN COLUMN A.

7400 1A
7400 2A
7400 3A
7401 1A
7401 2A

RESULT.

7400 1A,2A,3A
7401 1A,2A

OR IT COULD BE IN COLUMNS

7400 1A 2A 3A
7401 1A 2A

EITHER WAY THANKS TO ANYONE THAT CAN GIVE ME AN IDEA.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default FORMULA OR VB

Thank you that worked perfect.

"Gary''s Student" wrote:

This example assumes that the original data is on Sheet1 and the revised
format will be entered in Sheet2:

Sub newlist()
Set w1 = Sheets("Sheet1")
Set w2 = Sheets("Sheet2")
w2.Cells(1, 1).Value = w1.Cells(1, 1).Value
w2.Cells(1, 2).Value = w1.Cells(1, 2).Value
Ide = Cells(1, 1).Value
w1.Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 3
kk = 1
For i = 2 To n
If w1.Cells(i, 1).Value = Ide Then
w2.Cells(kk, k).Value = w1.Cells(i, 2).Value
k = k + 1
Else
kk = kk + 1
k = 3
Ide = w1.Cells(i, 1).Value
w2.Cells(kk, 1).Value = Ide
w2.Cells(kk, 2).Value = w1.Cells(i, 2).Value
End If
Next
End Sub

--
Gary''s Student - gsnu200773


"Tomkat743" wrote:

I AM HAVING TROUBLE TRYING TO FIGURE OUT WHICH FORMULA WOULD WORK BEST FOR
THE FOLLOWING OR IF I NEED TO HAVE VB TO DO THIS. I NEED TO PUT THE DATA FROM
COLUMN B IN THE SAME ROW IF I HAVE MATCHING DATA IN COLUMN A.

7400 1A
7400 2A
7400 3A
7401 1A
7401 2A

RESULT.

7400 1A,2A,3A
7401 1A,2A

OR IT COULD BE IN COLUMNS

7400 1A 2A 3A
7401 1A 2A

EITHER WAY THANKS TO ANYONE THAT CAN GIVE ME AN IDEA.

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
Regression Leverage Formula (Jerry W. Lewis or Mike Middleton)already have DFITS formula PJ[_3_] Excel Worksheet Functions 2 June 2nd 10 03:45 PM
copy formula down a column and have cell references change within formula brad New Users to Excel 5 May 13th 07 04:38 PM
Formula expected end of statement error, typing formula into cell as part of VBA macro [email protected] Excel Programming 1 July 20th 06 07:58 PM
Cell doesn't show formula result - it shows formula (CTRL + ' doe. o0o0o0o Excel Worksheet Functions 6 November 19th 04 03:13 PM
Commenting custom formula fields/formula on formula editor Muxer Excel Programming 2 July 24th 03 01:02 AM


All times are GMT +1. The time now is 01:13 AM.

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

About Us

"It's about Microsoft Excel"