• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA & [CODE] Tags

chirayu

Well-Known Member
Hi All,

Was wondering something with regards to VBA & CODE tags.

Majority of my code is indented. However I noticed that when I copy my code to the forum & paste it into the thread. My indents disappear & the code looks like a huge chunk, rather than respective bits and pieces. Does this happen to you & is there a fix other than manual re-edit on forum? Example:

Should be something like this:
Code:
Sub Something()

IF Blah = Blah Then
    'Do Something
    Do Until Blah
       If Not IsEmpty(Blah) Then
            'Do Something more
        Else
       End If
   Loop
Else
    'Do Nothing
End If

End Sub

But instead shows up like this:
Code:
Sub Something()

IF Blah = Blah Then
'Do Something
Do Until Blah
If Not IsEmpty(Blah) Then
'Do Something more
Else
End If
Loop
Else
'Do Nothing
End If

End Sub
 
No, it keeps indentations for me just fine...your source code, is it properly indented? You're using basic VBE and copy/paste right, not something like Notepad++ or something else? o_O
 
No, Direct Copy/paste doesn't encounter so far...

Code:
Sub get_data()
Dim ws As Worksheet, cFind As Range

For Each ws In ThisWorkbook.Worksheets

If ws.Name <> "I want Result like this." Then

    Set cFind = ws.Cells.Find("txn #")
       
        If Not cFind Is Nothing Then
           
            With cFind.CurrentRegion
 
Rechecked!!


Code:
Sub get_data()
Dim ws As Worksheet, cFind As Range

For Each ws In ThisWorkbook.Worksheets

If ws.Name <> "I want Result like this." Then

    Set cFind = ws.Cells.Find("txn #")
       
        If Not cFind Is Nothing Then
           
            With cFind.CurrentRegion
                .Offset(1).Resize(.Rows.Count - 1).Copy
            End With
 
Oh ok so I need to use code window? I usually just use the tags directly by typing them. Works with the window but not direct tags.

Code:
Sub SAMPLER()

'Save this as XYZ.CSV & send to ABC@123.com

If MsgBox("Would you like to create the XYZ.csv file", vbYesNo, "") = vbNo Then
    MsgBox "Macro Cancelled. Macro will now exit.", vbCritical, ""
    Exit Sub
Else

Dim DWIP As String
Dim NewWB As String
 
Back
Top