Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to compare cell contents and make calculations


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Macro to compare cell contents and make calculations

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to compare cell contents and make calculations


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Macro to compare cell contents and make calculations

You're welcome.

Stereolab wrote:
Rowan,

THANK YOU.

You are my hero.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COMPARE CELL CONTENTS guy Excel Worksheet Functions 4 December 24th 05 08:29 PM
compare cell contents guy Excel Worksheet Functions 2 December 23rd 05 08:38 PM
How do I make a cell's contents equal to another cell's contents with macro program? mgmcdevitt[_10_] Excel Programming 2 September 15th 05 09:44 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Function syntax to compare cell contents ES Excel Worksheet Functions 2 May 18th 05 03:53 PM


All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"