ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Macro - I Think? (https://www.excelbanter.com/excel-programming/310816-simple-macro-i-think.html)

vinclanz

Simple Macro - I Think?
 

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

--
vinclan
-----------------------------------------------------------------------
vinclanz's Profile: http://www.excelforum.com/member.php...fo&userid=1459
View this thread: http://www.excelforum.com/showthread.php?threadid=26221


Ron Rosenfeld

Simple Macro - I Think?
 
On Tue, 21 Sep 2004 17:39:02 -0500, vinclanz
wrote:


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


All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com