How to create output for a specific line in Macro?

Mosen87

New Member
Joined
Mar 9, 2020
Messages
36
I have a macro code and I want to make output for some lines. Is there a way? consider the following, I want to see what is the "ActiveCell.Offset(off, 0)"?
Sub Opter()
'Application.ScreenUpdating = False
'Call Module1.Iterations
Do While IsEmpty(ActiveCell.Offset(donum, 0)) = False
If mini = 1 Then
Call selecterMini
Else
Call selecter
End If
Set changev = Selection
ActiveCell.Offset(off, 0).Select
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
In the VBA editor, open the 'Immediate Window' from the VIEW drop down menu or press CTRL+G.

Then add this line of code to your macro at the point you wish to see the value.

Debug.Print ActiveCell.Offset(off,0)
 
Upvote 0
Thanks. How can I run only that line? When I put the cursor in the beginning of the line and press run into, It runs from the beginning of code which is not what I need.
2) And by doing "Debug.Print ActiveCell.Offset(off,0) " I get the value, how can I get the row and column for this value?
 
Upvote 0
Hi Mosen87,

You can execute your code line by line by pressing F8.

To get the address of the cell use;

Debug.Print ActiveCell.Offset(off,0).Address


In my previous reply, the line of code should have read;

Debug.Print ActiveCell.Offset(off,0).Value

Good luck
 
Upvote 0
How about
VBA Code:
Debug.Print ActiveCell.Offset(off,0).Address
 
Upvote 0
Hi Mosen87,

You can execute your code line by line by pressing F8.

To get the address of the cell use;

Debug.Print ActiveCell.Offset(off,0).Address


In my previous reply, the line of code should have read;

Debug.Print ActiveCell.Offset(off,0).Value

Good luck
Thanks JayM
When I press F8, which is the "step into" option in debug tab, It starts from beginning. I want to run only for example line 40. Do you know where I am missing!
 
Upvote 0
Select the line you want to start from & press F9, then press F5, the code will run until it gets to the break point, at which point you can use F8 to step through the rest of the code.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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