Fairly basic Excel 2007 VBA request

gedinfo

New Member
Joined
Aug 24, 2011
Messages
9
I have a spreadsheet that has a total of 2048 entries.
One column has a value(Column B), and another column will have text in it(Column G).

I wish to be able to search for "Maxima" and "Minima" in Column G, then pull out the value in Column B.

Here is what I have so far:

For Each Cell In Column(G)
If ActiveCell.Value = Maxima Then
Print "Maxima "; Cell; B; Value
If ActiveCell.Value = Minima Then
Print "Minima "; Cell; B; Value

Obviously, this does not work, but this is how I envision it to work.

What do I need to do to have it perform as described?

Thank you for your response.

I had done some VBA programming about 3 years ago, but never had a chance to save my macro code, which involved more complicated measures.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try like this

Code:
Sub atest()
Dim Found As Range
Set Found = Columns("G").Find(what:="Maxima", LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then MsgBox "Maxima" & vbTab & Found.Offset(, -5).Value
Set Found = Columns("G").Find(what:="Minima", LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then MsgBox "Minima" & vbTab & Found.Offset(, -5).Value
End Sub
 
Upvote 0
Not sure where you want your outputs to go, but if you wanted them to be in column G then perhaps something like this:
Code:
Dim LstRw As Long, Rw As Long
LstRw = Cells(Rows.Count, "G").End(xlUp).Row
For Rw = 1 To LstRw
  Select Case Cells(Rw, "G").Value
    Case "Maxima", "Minima"
      Cells(Rw, "G").Value = Cells(Rw, "G").Value & " " & Cells(Rw, "B").Value
  End Select
Next Rw

Hope it helps.
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top