bnp
0
Q:

how to continue formula in below line in vba code

'VBA uses the combination of a Space character AND an Underscore to 
'continue a line of code to the next line.

'For example:

MyVariable = ThisWorkbook.Worksheets("Sheet1").Range("A1").Value & _
             ThisWorkbook.Worksheets("Sheet2").Range("A1").Value
     
     
'------------------------------------------------------------------
'Caveat 1: The line break is not allowed 
'          in the middle of quoted literal text.

'Caveat 2: The line break can only happen where a Space character
'          would be allowed. For example, you are not allowed to
'          split up dot notation for an object's scope and
'          properties and methods.

'Caveat 3: One line of code can have a maximum of 24 line breaks.

'Caveat 4: One line of code can have a max of 1024 characters,
'          whether it is continued or not.
3
Sub CopyDown()
Dim Lastrow As String, FirstRow As String, strtCell As Range
'
' CopyDown Macro
' Copies the current cell to any empty cells below it.   
'
' Keyboard Shortcut: Ctrl+Shift+D
'
    Set strtCell = ActiveCell
    FirstRow = strtCell.Address
' Lastrow is address of the *list* of empty cells
    Lastrow = Range(Selection, Selection.End(xlDown).Offset(-1, 0)).Address
'   MsgBox Lastrow
    Range(Lastrow).Formula = strtCell.Formula

    Range(Lastrow).End(xlDown).Select
 End Sub
0
Range("M3") = "=G3&"",""&L3": Range("M3:M" & LastRow).FillDown
0
Range("$M$3").Formula = Range("G3") & (",") & Range("L3")

Dim Lastrow As Long

Application.ScreenUpdating = False

Lastrow = Range("L" & Rows.Count).End(xlUp).Row
Range("M4").FormulaR1C1 = Range("G4") & (",") & Range("L4")
Range("M4").AutoFill Destination:=Range("M4:M" & Lastrow)
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
0
Range("tablename[columnname]").Formula = "=G3&"",""&L3"
0

New to Communities?

Join the community