ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On File Open (https://www.excelbanter.com/excel-programming/397505-file-open.html)

Mir Khan

On File Open
 
Hi Experts, i have a question with three column involved in it.
column A (where a number is entered [if required] whenever the file is opened)
column J ( where the previous total is stored)
column P (P1=J1+A1)
when ever this file is opened Column A should get set to '0' (zero)
automatically, and column J should get the value that is stored in column P.

i am not sure if this makes any sense to you guys. please ask for
clarification.

PLEASE HELP!!!

Kevin B

On File Open
 
Change sheet name to match the sheet you want the update done in.

In the Workbook module place the following code:

Private Sub Workbook_Open()

With Sheets("Sheet1")
.Range("J1").Value = .Range("P1").Value
.Range("A1").Value = 0
End With

End Sub

--
Kevin Backmann


"Mir Khan" wrote:

Hi Experts, i have a question with three column involved in it.
column A (where a number is entered [if required] whenever the file is opened)
column J ( where the previous total is stored)
column P (P1=J1+A1)
when ever this file is opened Column A should get set to '0' (zero)
automatically, and column J should get the value that is stored in column P.

i am not sure if this makes any sense to you guys. please ask for
clarification.

PLEASE HELP!!!


Mir Khan

On File Open
 
Hi Sir it does not work for me...

"Kevin B" wrote:

Change sheet name to match the sheet you want the update done in.

In the Workbook module place the following code:

Private Sub Workbook_Open()

With Sheets("Sheet1")
.Range("J1").Value = .Range("P1").Value
.Range("A1").Value = 0
End With

End Sub

--
Kevin Backmann


"Mir Khan" wrote:

Hi Experts, i have a question with three column involved in it.
column A (where a number is entered [if required] whenever the file is opened)
column J ( where the previous total is stored)
column P (P1=J1+A1)
when ever this file is opened Column A should get set to '0' (zero)
automatically, and column J should get the value that is stored in column P.

i am not sure if this makes any sense to you guys. please ask for
clarification.

PLEASE HELP!!!


JE McGimpsey

On File Open
 
Do you have macros enabled?

Is the code in the ThisWorkbook code module?

What happens when you step through the code?

In article ,
Mir Khan wrote:

Hi Sir it does not work for me...

"Kevin B" wrote:

Change sheet name to match the sheet you want the update done in.

In the Workbook module place the following code:

Private Sub Workbook_Open()

With Sheets("Sheet1")
.Range("J1").Value = .Range("P1").Value
.Range("A1").Value = 0
End With

End Sub


Mir Khan

On File Open
 
I have Macros enabled and work with different other macros. when i step
through it it works the way the macro is designed but when i save and close
the file after entering data in column A and re-open the file nothing happens
column A, J and P remains the same.

Please help.

"JE McGimpsey" wrote:

Do you have macros enabled?

Is the code in the ThisWorkbook code module?

What happens when you step through the code?

In article ,
Mir Khan wrote:

Hi Sir it does not work for me...

"Kevin B" wrote:

Change sheet name to match the sheet you want the update done in.

In the Workbook module place the following code:

Private Sub Workbook_Open()

With Sheets("Sheet1")
.Range("J1").Value = .Range("P1").Value
.Range("A1").Value = 0
End With

End Sub



Mir Khan

On File Open
 
Hi Sir, nothing happens when i open the file. it works when i run it from the
visual basic editor.

i want it to work when we open the file.



"Mir Khan" wrote:

I have Macros enabled and work with different other macros. when i step
through it it works the way the macro is designed but when i save and close
the file after entering data in column A and re-open the file nothing happens
column A, J and P remains the same.

Please help.

"JE McGimpsey" wrote:

Do you have macros enabled?

Is the code in the ThisWorkbook code module?

What happens when you step through the code?

In article ,
Mir Khan wrote:

Hi Sir it does not work for me...

"Kevin B" wrote:

Change sheet name to match the sheet you want the update done in.

In the Workbook module place the following code:

Private Sub Workbook_Open()

With Sheets("Sheet1")
.Range("J1").Value = .Range("P1").Value
.Range("A1").Value = 0
End With

End Sub



JE McGimpsey

On File Open
 
You haven't answered as to whether the code is in the workbook code
module (by default named ThisWorkbook)...

If the code IS there, it will run automatically when you open the file.

In article ,
Mir Khan wrote:

Hi Sir, nothing happens when i open the file. it works when i run it from the
visual basic editor.

i want it to work when we open the file.



"Mir Khan" wrote:

I have Macros enabled and work with different other macros. when i step
through it it works the way the macro is designed but when i save and close
the file after entering data in column A and re-open the file nothing
happens
column A, J and P remains the same.

Please help.

"JE McGimpsey" wrote:

Do you have macros enabled?

Is the code in the ThisWorkbook code module?

What happens when you step through the code?


Mir Khan

On File Open
 
I didn't knew where workbook code module, but now i know and it is working
fine.

Thanks a bunch... JE McGimpsey :). I really appreciate your help.

"JE McGimpsey" wrote:

You haven't answered as to whether the code is in the workbook code
module (by default named ThisWorkbook)...

If the code IS there, it will run automatically when you open the file.

In article ,
Mir Khan wrote:

Hi Sir, nothing happens when i open the file. it works when i run it from the
visual basic editor.

i want it to work when we open the file.



"Mir Khan" wrote:

I have Macros enabled and work with different other macros. when i step
through it it works the way the macro is designed but when i save and close
the file after entering data in column A and re-open the file nothing
happens
column A, J and P remains the same.

Please help.

"JE McGimpsey" wrote:

Do you have macros enabled?

Is the code in the ThisWorkbook code module?

What happens when you step through the code?




All times are GMT +1. The time now is 07:23 PM.

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