VBA Writing style. Advise

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
1. I was writing macro manually and I dotn know what I did but the cursor blink became bold and I dont know how to return that to normal cursor mode
2. Is manual way of writing macro called relative macro or othewise what is it called....?
3. I have seen someone write a macro in style like below code....it move the line in and then come out again...
do we manually do that as does it automatically happen...
because when i write the code it does not happen...
Code:
Sub try2()
With Sheet1
  lr = .Cells(Rows.Count, "A").End(xlUp).Row
    For i = 2 To lr
      If .Cells(i, "D").Value >= .Cells(2, "H").Value Then
         .Range("A" & i & ":G" & lr).Copy Sheets("Home").Range("A1")
       Exit For
     End If
   Next i
 End With
End Sub
Thanks again!
 
Why would you want to do that and why would it be difficult to do?

If I saw code that had that sort of indentation the first thing I would do is faint, then I'd probably adjust it to make it readable before proceeding.

The add-in Nalani and I mentioned will allow you to do that with a couple of clicks.

PS I think the VBE does sometimes do some automatic indentation but I'm not sure, or I'm thinking of something completely different.:)
 
Upvote 0
If you download and install the Smart Indenter that I linked to above, then all you would have to do is go to the Edit Tab in the VBE and choose Smart Indent.

From there you have choices to Indet the module, procedure, Project, etc.

Edit: I use it quite a bit. Granted it sometimes doesn't indent exactly the way I want it for my reading, but that is easy to fix. And usally it's is a couple of lines, not the whole thing.
 
Last edited:
Upvote 0
Great thanks....:biggrin: Norie be careful...I'm sure there are some codes here that might cause u to F A I N T ....:biggrin: 'm #1:stickouttounge:


Thanks again for help!
 
Upvote 0
Nalani

Try indenting again if you don't get what you want.

Seems to work for me.

You might also want to check out some of the options eg for indenting declarations, select cases etc.
 
Upvote 0

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