Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to trigger one cell change to change another cell using VB in excel? Please help! :)
I am currently embarking on a school project regarding excel and
visual basic within excel. I have no prior knowledge to programming and my project is due very soon so please help if you can! :) Here's what I hope to achieve: There are 2 columns of cells. The value of the cells in the 2nd column will decrease given something to trigger it. What I hope is that the value by which the 2nd column decrease will be added to the value in the 1st column's cells. Does anyone know any way to do it and loop all the way downwards for all active cells? Please show me an example of the code and be as descriptive as you can as I'll probably take hours to read and understand it. Thanks a million! :) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to trigger one cell change to change another cell using VB in excel? Please help! :)
Generally we don't help with assignments, but as you admit yours is, here's
a start If your data is in say A1:B1000 you could do this (not the most elegant but it works) Sub SubtractBAddA() Dim myCell As Range For Each myCell In Range("A1:A1000") myCell.Value = myCell.Value + 1 Next myCell Set myCell = Nothing For Each myCell In Range("B1:B1000") myCell.Value = myCell.Value - 1 Next myCell End Sub To implement, decide how you trigger it and improve, well there's here, websites, etc...over to you -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England DTHIS www.nickhodge.co.uk "raytan" wrote in message ups.com... I am currently embarking on a school project regarding excel and visual basic within excel. I have no prior knowledge to programming and my project is due very soon so please help if you can! :) Here's what I hope to achieve: There are 2 columns of cells. The value of the cells in the 2nd column will decrease given something to trigger it. What I hope is that the value by which the 2nd column decrease will be added to the value in the 1st column's cells. Does anyone know any way to do it and loop all the way downwards for all active cells? Please show me an example of the code and be as descriptive as you can as I'll probably take hours to read and understand it. Thanks a million! :) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to trigger one cell change to change another cell using VB in excel? Please help! :)
Hi,
I am currently embarking on a school project regarding excel and visual basic I have no prior knowledge to programming Which doesn't make things any easier. I don't know whether what you want is possible at all. This one deducts a random value from 1 to 10 from all cells in column 2, and adds it to all cells in columns 1. Public Sub Test80x() Dim lngR As Long ' row Dim lngX As Long ' just a value Dim lngY As Long ' just a value Randomize lngX = CLng((9 * Rnd) + 1) lngR = Cells(Rows.Count, 1).End(xlUp).Row For lngY = 1 To lngR Cells(lngY, 2).Value = Cells(lngY, 2).Value - lngX Cells(lngY, 1).Value = Cells(lngY, 1).Value + lngX Next End Sub See help for all and everything. Sorry. ;-) -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to trigger one cell change to change another cell using VB in excel? Please help! :)
Ideally this could be done if we had access to what triggers the cell
change. Since we apparently don't, we need to somehow get the original value of column B before it was changed. Assuming the value change will trigger the Worksheet_Change event, we could use that to capture the new value and use the Application.Undo method to capture the original value. Then subtract new value from original value and add the difference to column A. Finally, assign column B back to the new value. Mike F "raytan" wrote in message ups.com... I am currently embarking on a school project regarding excel and visual basic within excel. I have no prior knowledge to programming and my project is due very soon so please help if you can! :) Here's what I hope to achieve: There are 2 columns of cells. The value of the cells in the 2nd column will decrease given something to trigger it. What I hope is that the value by which the 2nd column decrease will be added to the value in the 1st column's cells. Does anyone know any way to do it and loop all the way downwards for all active cells? Please show me an example of the code and be as descriptive as you can as I'll probably take hours to read and understand it. Thanks a million! :) |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to trigger one cell change to change another cell using VB in excel? Please help! :)
Oh and I'm thinking how do I trigger it such that it autocalculates
whenever the value in cell 2 decreases? such that the cell 1 will automatically go up? cos the value by which cell 2 decreases in triggered by another worksheet in the same file.. thanks a lot! On Mar 25, 5:11 pm, "raytan" wrote: I am currently embarking on a school project regarding excel and visual basic within excel. I have no prior knowledge to programming and my project is due very soon so please help if you can! :) Here's what I hope to achieve: There are 2 columns of cells. The value of the cells in the 2nd column will decrease given something to trigger it. What I hope is that the value by which the 2nd column decrease will be added to the value in the 1st column's cells. Does anyone know any way to do it and loop all the way downwards for all active cells? Please show me an example of the code and be as descriptive as you can as I'll probably take hours to read and understand it. Thanks a million! :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Trigger macro when specific cell doesn't change | Excel Programming | |||
Trigger Macro on change in cell value | Excel Programming | |||
Cell change to trigger Macro | Excel Programming | |||
Cell value change to trigger macro (worksheet change event?) | Excel Programming |