Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
calling macros from worksheet to another
I have created a macro in sheet1 and stored it in view code of sheet1.
Now I copy the contents to sheet1 and also the viewcode to sheet2, but it does not work. Can anyone help me in this matter. Also How can I access or refer data/cells from one worksheet/Excel file in other worksheet/Excel file while creating macros. NSNR -- reply to my posts are welcome |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
calling macros from worksheet to another
It would help if you showed your code.
-- HTH, Barb Reinhardt "NSNR" wrote: I have created a macro in sheet1 and stored it in view code of sheet1. Now I copy the contents to sheet1 and also the viewcode to sheet2, but it does not work. Can anyone help me in this matter. Also How can I access or refer data/cells from one worksheet/Excel file in other worksheet/Excel file while creating macros. NSNR -- reply to my posts are welcome |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
calling macros from worksheet to another
PL FIND THE CODE AS FOLLOWS:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim jjj6, jj6, jj8 As Range Dim dp As Integer Set jjj6 = Cells(10, 6) Set jjj7 = Cells(10, 7) Set jjj8 = Cells(11, 3) 'Lengthtobeinput = InputBox("Enter Length", "Input", 1) 'Breadthtobeinput = InputBox("Enter Breadth", "Input", 1) 'Heighttobeinput = InputBox("Enter Height", "Input", 1) 'Cells(5, 3) = Lengthtobeinput 'Cells(7, 3) = Breadthtobeinput 'Cells(9, 3) = Heighttobeinput 'Cells(7, 5) = (Lengthtobeinput * Breadthtobeinput * Heighttobeinput) / (1000000000) Cells(7, 5) = (Cells(5, 3) * Cells(7, 3) * Cells(9, 3)) / (1000000000) 'ActiveCell.Offset(5, 4).Select dp = Cells(7, 3).Value If Cells(7, 3).Value = Cells(24, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(24, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(24, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(24, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(24, 11).Value Else If Cells(7, 3).Value = Cells(26, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(26, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(26, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(26, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(26, 11).Value Else If Cells(7, 3).Value = Cells(28, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(28, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(28, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(28, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(28, 11).Value Else If Cells(7, 3).Value = Cells(30, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(28, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(28, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(28, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(28, 11).Value Else If Cells(7, 3).Value = Cells(32, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(32, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(32, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(32, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(32, 11).Value Else If Cells(7, 3).Value = Cells(34, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(34, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(34, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(34, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(34, 11).Value Else If Cells(7, 3).Value = Cells(36, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(36, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(36, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(36, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(36, 11).Value Else If Cells(7, 3).Value = Cells(38, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(38, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(38, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(38, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(38, 11).Value Else If Cells(7, 3).Value = Cells(40, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(40, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(40, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(40, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(40, 11).Value Else End If End If End If End If End If End If End If End If End If End Sub -- reply to my posts are welcome "Barb Reinhardt" wrote: It would help if you showed your code. -- HTH, Barb Reinhardt "NSNR" wrote: I have created a macro in sheet1 and stored it in view code of sheet1. Now I copy the contents to sheet1 and also the viewcode to sheet2, but it does not work. Can anyone help me in this matter. Also How can I access or refer data/cells from one worksheet/Excel file in other worksheet/Excel file while creating macros. NSNR -- reply to my posts are welcome |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
calling macros from worksheet to another
Is there a reason that you have this kind of code under the _selectionchange
event. This means that each time you select a different range, the code will fire and try to do stuff. I think I'd remove the code from each worksheet module and put a single copy in a General module. Then you can use: if activesheet.cells(x, y).value = worksheets("sheet2").cells(z,w).value then to refer to different sheets (if the activesheet is not Sheet2). NSNR wrote: PL FIND THE CODE AS FOLLOWS: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim jjj6, jj6, jj8 As Range Dim dp As Integer Set jjj6 = Cells(10, 6) Set jjj7 = Cells(10, 7) Set jjj8 = Cells(11, 3) 'Lengthtobeinput = InputBox("Enter Length", "Input", 1) 'Breadthtobeinput = InputBox("Enter Breadth", "Input", 1) 'Heighttobeinput = InputBox("Enter Height", "Input", 1) 'Cells(5, 3) = Lengthtobeinput 'Cells(7, 3) = Breadthtobeinput 'Cells(9, 3) = Heighttobeinput 'Cells(7, 5) = (Lengthtobeinput * Breadthtobeinput * Heighttobeinput) / (1000000000) Cells(7, 5) = (Cells(5, 3) * Cells(7, 3) * Cells(9, 3)) / (1000000000) 'ActiveCell.Offset(5, 4).Select dp = Cells(7, 3).Value If Cells(7, 3).Value = Cells(24, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(24, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(24, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(24, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(24, 11).Value Else If Cells(7, 3).Value = Cells(26, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(26, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(26, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(26, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(26, 11).Value Else If Cells(7, 3).Value = Cells(28, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(28, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(28, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(28, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(28, 11).Value Else If Cells(7, 3).Value = Cells(30, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(28, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(28, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(28, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(28, 11).Value Else If Cells(7, 3).Value = Cells(32, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(32, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(32, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(32, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(32, 11).Value Else If Cells(7, 3).Value = Cells(34, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(34, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(34, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(34, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(34, 11).Value Else If Cells(7, 3).Value = Cells(36, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(36, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(36, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(36, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(36, 11).Value Else If Cells(7, 3).Value = Cells(38, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(38, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(38, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(38, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(38, 11).Value Else If Cells(7, 3).Value = Cells(40, 3).Value Then Cells(7, 7) = Cells(7, 5).Value * Cells(40, 5).Value Cells(7, 8) = Cells(7, 5).Value * Cells(40, 7).Value Cells(7, 10) = Cells(7, 5).Value * Cells(40, 9).Value Cells(7, 11) = Cells(7, 5).Value * Cells(40, 11).Value Else End If End If End If End If End If End If End If End If End If End Sub -- reply to my posts are welcome "Barb Reinhardt" wrote: It would help if you showed your code. -- HTH, Barb Reinhardt "NSNR" wrote: I have created a macro in sheet1 and stored it in view code of sheet1. Now I copy the contents to sheet1 and also the viewcode to sheet2, but it does not work. Can anyone help me in this matter. Also How can I access or refer data/cells from one worksheet/Excel file in other worksheet/Excel file while creating macros. NSNR -- reply to my posts are welcome -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
calling worksheet function from a macro | Excel Worksheet Functions | |||
calling up information from a different worksheet. | Excel Worksheet Functions | |||
Calling a specific worksheet from a hyperlink in a seperate file. | Excel Worksheet Functions | |||
Calling macros in another workbook | Excel Worksheet Functions | |||
calling a series macros with a marco | Excel Discussion (Misc queries) |