Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, I'm trying to write a macro that will downcount inventory on an Exce spreadsheet as long as the part number value has not changed. My logic is as follows: If (Part current) = (Part previous), then Stock (current row) = Stoc (previous row) - Qty (previous row) I tried to code this in VB as follows: If Cells(-1, -3) = Cells(0, -3) Then Cells(0, 6) = Cells(-1, 6) - Cell (-1, 1) This doesn't work, and I am not sure why. I have played around wit parentheses, added ".Value", and anything else I thought might work Can anyone help? Thanks in advance -- Stereola ----------------------------------------------------------------------- Stereolab's Profile: http://www.excelforum.com/member.php...fo&userid=2863 View this thread: http://www.excelforum.com/showthread.php?threadid=48295 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe like this:
With ActiveCell If .Offset(-1, -3) = .Offset(0, -3) Then _ .Offset(0, 6) = .Offset(-1, 6) - .Offset(-1, 1) End With Hope this helps Rowan Stereolab wrote: Hello, I'm trying to write a macro that will downcount inventory on an Excel spreadsheet as long as the part number value has not changed. My logic is as follows: If (Part current) = (Part previous), then Stock (current row) = Stock (previous row) - Qty (previous row) I tried to code this in VB as follows: If Cells(-1, -3) = Cells(0, -3) Then Cells(0, 6) = Cells(-1, 6) - Cells (-1, 1) This doesn't work, and I am not sure why. I have played around with parentheses, added ".Value", and anything else I thought might work. Can anyone help? Thanks in advance. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Rowan, THANK YOU. You are my hero. -- Stereolab ------------------------------------------------------------------------ Stereolab's Profile: http://www.excelforum.com/member.php...o&userid=28635 View this thread: http://www.excelforum.com/showthread...hreadid=482951 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're welcome.
Stereolab wrote: Rowan, THANK YOU. You are my hero. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
COMPARE CELL CONTENTS | Excel Worksheet Functions | |||
compare cell contents | Excel Worksheet Functions | |||
How do I make a cell's contents equal to another cell's contents with macro program? | Excel Programming | |||
Macro to remove contents of cell and move all other contents up one row | Excel Discussion (Misc queries) | |||
Function syntax to compare cell contents | Excel Worksheet Functions |