Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling worksheet function from a macro Joe Farruggio Excel Worksheet Functions 3 November 20th 06 10:01 PM
calling up information from a different worksheet. Jay Adams Excel Worksheet Functions 0 October 8th 06 09:33 AM
Calling a specific worksheet from a hyperlink in a seperate file. TheChris Excel Worksheet Functions 0 February 2nd 06 01:48 AM
Calling macros in another workbook Nick Wright Excel Worksheet Functions 1 January 12th 06 04:03 PM
calling a series macros with a marco gerry405 Excel Discussion (Misc queries) 0 October 18th 05 01:23 PM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"