macro need

gigiyi

Board Regular
Joined
May 11, 2009
Messages
205
Hi,

I have a spreadsheet to keep track the daily remain resourses (%) as shown below. The highlight cells are type in manually everyday.

Without using formula, could someone helping me to get the outsome using macro? Any help is appreciated.



<TABLE style="BACKGROUND-COLOR: #ffffff; PADDING-LEFT: 2pt; PADDING-RIGHT: 2pt; FONT-FAMILY: Calibri,Arial; FONT-SIZE: 11pt" border=1 cellSpacing=0 cellPadding=0><TBODY><TR style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt; FONT-WEIGHT: bold"><TD> </TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">1</TD><TD>Day</TD><TD>Resources</TD><TD>Resources used up</TD><TD>Resources used up %</TD><TD>Remain Resourses</TD><TD>Remain Resourses %</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">2</TD><TD style="TEXT-ALIGN: right">1</TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffffcc">1000</TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffffcc">200</TD><TD style="TEXT-ALIGN: right">20.00%</TD><TD style="TEXT-ALIGN: right">800</TD><TD style="TEXT-ALIGN: right">80.00%</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">3</TD><TD style="TEXT-ALIGN: right">2</TD><TD style="TEXT-ALIGN: right">800</TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffffcc">50</TD><TD style="TEXT-ALIGN: right">5.00%</TD><TD style="TEXT-ALIGN: right">750</TD><TD style="TEXT-ALIGN: right">75.00%</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">4</TD><TD style="TEXT-ALIGN: right">3</TD><TD style="TEXT-ALIGN: right">750</TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffffcc">150</TD><TD style="TEXT-ALIGN: right">15.00%</TD><TD style="TEXT-ALIGN: right">600</TD><TD style="TEXT-ALIGN: right">60.00%</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">5</TD><TD style="TEXT-ALIGN: right">4</TD><TD style="TEXT-ALIGN: right">600</TD><TD style="TEXT-ALIGN: right; BACKGROUND-COLOR: #ffffcc">250</TD><TD style="TEXT-ALIGN: right">25.00%</TD><TD style="TEXT-ALIGN: right">350</TD><TD style="TEXT-ALIGN: right">35.00%</TD></TR></TBODY></TABLE>
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Rich (BB code):
Sub WorkSheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C2:C" & Rows.Count)) Is Nothing Then Exit Sub


'This sub will be triggered whenever a new value is entered
'on this sheet and will run if that change is in Column "C".

'Prevent changes made by this sub from triggering this sub.

Application.EnableEvents = False

Dim StartingResources As Long
StartingResources = Range("B2").Value


'Resources
   Target.Offset(1, -1).Value = _
      Target.Offset(0, -1).Value - Target.Value
'Resources used up
   'The Target itself
'Resources used up %
   Target.Offset(0, 1).Value = _
      Target.Value / StartingResources
'Remain Resourses
   Target.Offset(0, 2).Value = _
      Target.Offset(0, -1).Value - Target.Value
'Remain Resourses %
   Target.Offset(0, 3).Value = _
      Target.Offset(0, 2).Value / StartingResources


Application.EnableEvents = True
End Sub


</PRE>
 
Last edited:
Upvote 0
Without using formula, could someone helping me to get the outsome using macro? Any help is appreciated.
Is there a particular reason for not being able to use formulas? After all any macro to perform this task will need to use formulas anyway.
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top