Posts

Showing posts from July, 2018

Userforms, TexBoxes & Condition Matching in Excel VBA

Suppose, TextBox1.Value = 10 and TextBox2.Value = 10 also, if you pass this following coding it gives the wrong result. If TextBox1.value = TextBox2.value then      MsgBox "Yes They are Equal" Else     MsgBox "No, They are not Equal" End if You will defiantly get the second message and that is, "No, They are not Equal!" So why does it happens? In Excel VBA, when you are dealing with Userforms, sometimes work demands an use of conditional matching criteria. Just like, IF the value of textbox1 is equal to textbox2 then do something. just like that. So, Textboxes have always stored values entered in it as String Format. yes even if it's number or not. So, when do we matching the two textboxes based on numbers then we will surely not get the correct result. So there are two ways to get rid of this. 1. Use Val function 2. Store the Value of TextBoxes into the Worksheet Range. 1. Use of Val Function If Val(TextBox1.value) = Val(Tex

Making VBA Development Version Independent Part 1

Making VBA Development Version Independent, will require focussed research and I think it's still "long" to go... ( Here "long" is not data type :P )  I tried my best to hell throughout VBA versioning issues but sometimes VBA itself has limitations which keep us behind the facility of distributing the spreadsheets.  We need to solve every issue on a particular basis.  So Let's try that first particular. :D >> Finding the Last Empty Row of Worksheet Data << This is most common task amongst every VBA Tasks. There are multiple ways to get the last empty row but the easiest way is following mentioned. (I use it every time!) '/------------------- 'Finding Last Empty Row of Sheet1 Sub Test()     Dim LROW as Long      With Thisworkbook.Sheets("Sheet1")     LROW = .cells(.Rows.count, 1).End(XlUp).Row + 1     End With      Msgbox LROW End Sub '/------------------- Above subprocedure will throw Last Empty Row Number through Message Bo