ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Edit a Literal or Integer (https://www.excelbanter.com/excel-programming/401388-edit-literal-integer.html)

Rick

Edit a Literal or Integer
 
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


sebastienm

Edit a Literal or Integer
 
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,
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Rick" wrote:

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


Don Guillett

Edit a Literal or Integer
 
Option Explicit
Dim oldvalue As Double

Sub zerooldvalue()'reset
oldvalue = 0
End Sub

Sub doval()
oldvalue = oldvalue + 5
MsgBox oldvalue
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rick" wrote in message
...
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



Rick

Edit a Literal or Integer
 
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.

"Rick" wrote:

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



All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com