Use a Interger from one Module to another one

Gwhaou

Board Regular
Joined
May 10, 2022
Messages
78
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Actually I'm trying to copy some information from one sheet to another sheet, I don't want to mix all the data so I'm searching the last empty row and paste the other information from the last empty row number defined on the Interge Num.

VBA Code:
Public Sub copy_paste()

Dim Num As Integer
Call Arr_Prg_Plnt ' Copy some Information from on column to another sheet column
Range("A1").End(xlDown).Offset(1).Select ' Select the last empty cell ' Reach the last empty cell of the column
Num = ActiveCell.Row 'Take the row number
Call Dep2_Prg_Plnt 'Copy some Information from on column to another sheet column, but I try to associate with the Interger Num
----- Dep2_Prg_Plnt is on another Module -------------

VBA Code:
Sub Dep2_Prg_Plnt()

Sheets("Dep2").Select
  
    Range("A6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("PasteSheet").Select
    Range("D" & Num).Select ' I want to associate the Num number defined one Module 1 to this Module
    ActiveSheet.Paste

But it's not working, Is possible to use saved Integer from one module to another module
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try:
VBA Code:
Sub copy_paste
    With Sheets("Dep2")
        .Range("A6", .Range("A" & .Rows.Count).End(xlUp)).Copy Sheets("PasteSheet").Cells(Sheets("PasteSheet").Rows.Count, "D").End(xlUp).Offset(1)
    End With
End Sub
 
Upvote 0
I want to use the Interger Num to fixe that empty row, because i simplified the code but I have a lot of column to copy (A, B, C, D...) and copy that to the sheet Dep2 in which Num take the last Empty row value.
I don't if you understant my problem.

Look the Dep2 sheet :
1654784778758.png


Here Call Arr_Prg_Plnt paste information from one sheet to here cell A2 to A9, Then From A1 it's looking for the last row which is saved one the Integer Num (here row 10)
Then I Call Dep2_Prg_Plnt from a another module, this script suppose to copy information from A6 to this sheet and place that from D10 (that's why i'm using Num to define that last row)

Sorry, I'm not that good in english.
 
Upvote 0
Please use code tags to post the code for Arr_Prg_Plnt. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach screenshots (not pictures) of your two sheets. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
You can use
VBA Code:
Call Dep2_Prg_Plnt(Num)  'Copy some Information from on column to another sheet column, but I try to associate with the Interger Num
to pass a variable to another sub & then use
VBA Code:
Sub Dep2_Prg_Plnt(Num As Long)
 
Upvote 0
Solution
You can use
VBA Code:
Call Dep2_Prg_Plnt(Num)  'Copy some Information from on column to another sheet column, but I try to associate with the Interger Num
to pass a variable to another sub & then use
VBA Code:
Sub Dep2_Prg_Plnt(Num As Long)
Thank's it works 🙏
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top