Search : in
By :

Vba Help needed

Last answer on Jul 16, 2009 2:46:26 am BST myrcka, on Jul 14, 2009 6:54:47 am BST 
 Report this message to moderators

Hello,

im having an issue, what im whant to achive is this. i want to be able to select ranges depending on the content of the cells in column A, and then copy the higest number in the same rows in column C. so lets say the data look like this

A B C

hello 3
hello 5
hello 6
hello 8
hey 2
hey 9
yo 10
yo 7
yo 15

what i then want, is to print the value 8 to a spesefic location and then print the number 9 to an other location, and the number 15 to an other location again. the data may not look like this and the length of the collumns is always different so the macro needs to be totaly dynamic.

hope it is possible to understand what i want to be able to achive.

im a total newbie to Vba, and i am grateful for any help.

Best answers for « Vba Help needed » in :
[VBA/VB6] My Documents + Environment Variables Show [VBA/VB6] My Documents + Environment Variables With VBA With VB6 Environment Functions Windows Variables Getting started As displayed in Windows Explorer, the My Documents folder appears to be in the root, but it is not the case. It...
[VBA] Detecting changes in cell Show [VBA] Detecting changes in cell The Event Change feature of a sheet will detects the change in the active cell but it gives no information about the content. The example given below will help you to find out if the cell was changed,...
VBA A simple second Timer Show VBA A simple second Timer In VBA, there is Timer feature available,but you can create one very easily. In a module sheet: Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'For example: Start / Stop the timer every...
Adding a VBA CommandButton with its respective the code ShowAdding a VBA CommandButton with its respective the code Paste these two sub in a general module (Module1 for example). Sub CreateButton() Dim Obj As Object Dim Code As String Sheets("Sheet1").Select 'create button ...
[VBA: VB6] Using excel from another application Show[VBA: VB6] Using excel from another application Here is a little routine to call Excel from VB6 or another Office application. Paste in a general module (eg Module1) In VBA>> Insert>> Module and paste in the window ... In VB6>>...
VBA: How to know everything about the file folder ShowVBA: How to know everything about the file folder Preliminaries In module In sheet1 module Preliminaries Open a new workbook Add a module In module ' Declare variables for wizard. Public balloon1 As Balloon Public balloon2...
Download Reliable Task Timer ShowReliable Task Timer is a timer for calculating precise time you have spent on a specific task. The program records the following information to a CSV spreadsheet: - task start date and time, - task end date and time, - task name, - task...
Worksheet - Cells ShowThe Concept of a Cell A "cell" is the intersection between a line (horizontal) and a column (vertical) on a worksheet. Thus, the name of the line combined with the name of the column gives the cell's coordinates (the term address is sometimes also...
Hyperlinks ShowIntroduction to anchors Hypertext links or hyperlinks (anchors) are HTML elements that, when clicked on, enable readers to visit a new address. Hyperlinked text is underlined by default. Hyperlinks are what connect web pages to one another. They...
Management organizational chart ShowManagement organizational chart A project must be included in the general objectives of the business, because it generally mobilizes personnel for a long period of time. This is why it is necessary for an organization to determine its intentions in...

1

 venkat1926, on Jul 16, 2009 2:46:26 am BST
  • +1

It is possible to write a macro but it is becoming complicated.

I am giving a hybrid solution. see whether it is helpful to you

your data sheet will be like this

A B C D E F h1 h2 hello hey yo
hello 3 5 7 10
hello 5
hello 6
hello 8
hey 2
hey 9
yo 10
yo 7
yo 15

the entries in D1,E1,F1 are clear
if you have more unique entries in col. A you can extend
further than F1.

the formula in D2 is

=MATCH(MAX(IF($A$1:A$100=D1,B1:$B$100)),$B$1:$B$100,0)

NOW INVOKE THIS FORMULA BY CONTROL+SHIFT+ENTER
copy D2 to E2 abd F2(if necessary beyond)

note that the values in D2,E2,F2 give the ROW NUMBER of the maximum value in col B corresponding to different entries like hello etc in column A

now I have created a small macro

Sub test()
Dim j As Integer, k As Integer, rng As Range
Worksheets("sheet2").Cells.Clear
Worksheets("sheet1").Activate
Set rng = Range(Range("d2"), Range("d2").End(xlToRight))
j = WorksheetFunction.Count(rng)
'MsgBox j
For k = 1 To j
Cells(Range("d2").Offset(0, k - 1).Value, "b").Copy Worksheets("sheet2").Cells(Rows.Count, "a").End(xlUp).Offset(1, 0)
Next k
End Sub



when you run the macro the number 5,7,10 are copied in sheet 2.
modify the macro to suit you

Reply to venkat1926