Edit a Literal or Integer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here's a toughfy? How does one edit the following to be the following by
using a macro?

Sheet1End = 13
Sheet1End = 18

The macro has to take a count of 5 and add it to whatever Sheet1End 1st
redition is equal to.
Something like Sheet1End = Sheet1End + 5 and make it 18 so that the next
time that the program is run again it starts off as Sheet1End = 18
 
Hi,

Not sure I get it, but if you are trying to store a value between multiple
runs of a macro then you could use a cell to store the number.
Eg, say Sheet2 is a hidden sheet.

Sub Macro1()
Dim theValue as Long

''' get the value
theValue=Sheet2.Range("A1").value

''' run macro code
''' here

''' Now store the new value
Sheet2.Range("A1").value = theValue + 5

End Sub

Now, if Sheet1End correspond to the last row of data (ie you are trying to
find the last row containing data in Sheet1), you can get that range using:
Dim rgEnd as range
set rgEnd = sheet1.Range("A:A").cells.count ''' get last cell of sheet1
in col A
set rgEnd = rgEnd.End(xlUp) ''' go up until last cell of data
msgbox rgEnd.Address

I hope this helps,
 
Option Explicit
Dim oldvalue As Double

Sub zerooldvalue()'reset
oldvalue = 0
End Sub

Sub doval()
oldvalue = oldvalue + 5
MsgBox oldvalue
End Sub
 
Thanks Guy's for trying to answer my querry. I had a feeling that no
permenate edit could be done on a macro by a macro. Maybe someday MS will
come up with a way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top