Simple Macro - I Think?

  • Thread starter Thread starter vinclanz
  • Start date Start date
V

vinclanz

My need should be very elementary for an Excel savvy person. Obviously
I'm not that savvy.

Having said that...here's my dilemna.

I have two columns in one spreadsheet with various columns linked t
another spreadsheet. One column (Column B) in one of the spreadsheet
calculates a value from the other spreadsheet.

Column A has a constant number that was originally keyed in.

All I need to do is test the following:

IF COLUMN B > COLUMN A, COPY THAT VALUE TO COLUMN A.

IF COLUMN B < COLUMN A, DO NOT REPLACE THE VALUE IN COLUMN A.

IF COLUMN B = COLUMN A, DO NOT REPLACE THE VALUE IN COLUMN A

Your help will be greatly appreciated
 
My need should be very elementary for an Excel savvy person. Obviously,
I'm not that savvy.

Having said that...here's my dilemna.

I have two columns in one spreadsheet with various columns linked to
another spreadsheet. One column (Column B) in one of the spreadsheets
calculates a value from the other spreadsheet.

Column A has a constant number that was originally keyed in.

All I need to do is test the following:

IF COLUMN B > COLUMN A, COPY THAT VALUE TO COLUMN A.

IF COLUMN B < COLUMN A, DO NOT REPLACE THE VALUE IN COLUMN A.

IF COLUMN B = COLUMN A, DO NOT REPLACE THE VALUE IN COLUMN A.

Your help will be greatly appreciated.

====================
Sub BgtA()
Dim rg As Range
Dim c As Range

Set rg = [B1:B100] 'set this to the appropriate range of B

For Each c In rg
If c.Value > c.Offset(0, -1).Value Then
c.Offset(0, -1).Value = c.Value
End If
Next c

End Sub
=====================


--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top