Skip to main content

Posts

Showing posts from April, 2017

Handling merged cell in Excel VBA

Merged cell is very common while we need to summarize some columns or rows in Excel. In order to automatically format the table, handling merged cell with VBA is necessary. Let's see some examples! Create a merged cell ActiveSheet.Range("B2:C4").Merge Check if a range is merged cell Debug.Print ActiveSheet.Range("B2").MergeCells 'True Debug.Print ActiveSheet.Range("C3").MergeCells 'True Debug.Print ActiveSheet.Range("B4").MergeCells 'True Debug.Print ActiveSheet.Range("D2").MergeCells 'False Get address/column/row of merged cell Dim objRangeToMerge As Range Set objRangeToMerge = ActiveSheet.Range("B2:C4") objRangeToMerge.Merge Dim objMergedCell As Range Set objMergedCell = objRangeToMerge.Cells(1) Debug.Print objMergedCell.Address '$B$2 Debug.Print objMergedCell.Column '2 Debug.Print objMergedCell.Row '2 Get merged columns/rows If ActiveSheet.Range("B2").MergeC

Measurement units conversion in Excel VBA

There are 2 native functions for converting measurement units. One is to convert Centimeters to Points, another one is to convert Inches to Points. They are easy to use and very useful when we need to set the size of columns and rows. Centimeters to Points Points = Application.CentimetersToPoints( Centimeters ) Reference:  MSDN - Application.CentimetersToPoints Method (Excel) Inches to Points Points = Application.InchesToPoints( Inches ) Reference:  MSDN - Application.InchesToPoints Method (Excel)

Apply CSS to Properties in Aras Innovator

Sometimes we need fill color or change text color to emphasize particular information. For example, if states of documents have different colors, users will be easier to identify information that they need, like below picture: There is a system property named "css" which could store item's style, but how to assign the style to property? The only thing we need to do is specify property name as a CSS class. .state { background-color: #B3FF99; } Here is an example to show how dynamically assign above style: Dim objItem As Item Dim strState As String Dim strColor As String For i As Integer = 0 To Me.getItemCount()-1 objItem = Me.getItemByIndex(i) strState = objItem.getProperty("state","") Select strState Case "Released" strColor = "#B3FF99" Case "Preliminary" strColor = "#FFFF99" Case Else strColor = "#fff" En

Hello World

Hi everybody, perhaps we are not know each other, but thanks to internet, we could use text to communicate worldwide. This blog will help me to note down something and may help you in the future. If there is any mistake or wrong thing, please also feel free to let me know. Just grown our knowledge together!