sábado, 30 de septiembre de 2017

How to get Row and Columns with Excel VBA - VSTO 2017 - Split Function


How to get Row and Columns with Split Function

How to split an Excel cell address

See More - MyExcelTools VBA section

Use the properties row and column position:


Range("Z35000").row
Range("Z7898989").column
Columns("M:M").column

Columns(selection.columns(5)).column

Rows(selection.rows(75)).rows

Get the row, column and set new address

Dim lRow as long, ICol as integer

lRow = Range("Z678").Row : ICol = Range("Z678").Column
‘Test my Cell address
Dim Myrng As Range: Set Myrng= Cells(lRow, ICol)

Myrng.Interior.Color=255


Msgbox Myrng .address

‘Split multiple selection of cells in Excel:

cell_address=Selection.address  
‘ This return  cell_address = "$F$77,$Z$22:$G$88"
Dim NewValues()as string

NewValues=Split (NewValues, ",")
NewValues(0)= "$F$77" : NewValues(1)= "$Z$22" : : NewValues(1)= "$G$88"

‘Change parameters Address (false,false) , Address(false,true) to split in other manner with separator as quick references ([$Column$] or [$Rownumber,])

Bonus:
Join ranges as one
Union(Range("F200:F700"), Range("C500:C900"), Range("J100:J400"))




No hay comentarios: