• Home
  • Blog
  • Resume
  • Contact
  • Projects
  • Gallery
  • Amit’s Resume
  • About Nagpur
KEEP IN TOUCH

Posts tagged cells

Count cells without formulae

Aug07
2006
Leave a Comment Written by admin

If you want to count cells in a given range without formulae use this function

Function CountNoFormula(rng As Range) As Long
Dim c As Range
   On Error GoTo CountNoFormula_Error
    For Each c In rng
        If Not c.HasFormula Then
            CountNoFormula = CountNoFormula + 1
        End If
    Next c
CountNoFormula_CleanUpExit:
   Exit Function
CountNoFormula_Error:
    CountNoFormula = CVErr(Err.Number)
    Resume CountNoFormula_CleanUpExit
End Function

If you want to count cells with formule then just remove then “Not” in front of c.HasFormula

Posted in Uncategorized - Tagged count

True blanks

Apr23
2005
Leave a Comment Written by admin

This about the problem of cells which appear to be blank and which are true blanks. If you check a cell using IsBlank() formula, you’d know if it’s a true blank or not.

Even if you copy paste special (values) this =”", there wouldn’t be anything in the cell and length of that cell would be zero – still it won’t be a blank. But if you press delete on that cell it would become a true blank.

Now, here is a macro to do the same thing, it would check if the cell has zero length and check if Istext is true, if both conditions are satisfied it would press a delete key on that cell.

Please check the Excel help on the functions- Len, Istext, and Isblank

To use this macro Press Alt + F11, double click the sheet you’re working on, copy and paste this code. Close VBA window.
To run it, select a range in the worksheet you want true blanks, press Alt + F8, select this macro and press Run.

‘macro to make a blank true blank
Sub make_true_blanks()
Dim c As Range
For Each c In Selection
If Len(c) = 0 And WorksheetFunction.IsText(c) Then
c.ClearContents
End If
Next
MsgBox “Done”
End Sub

Please check this discussion on mrexcel.com.

Posted in Uncategorized - Tagged Alt F8, Press Alt F11

Flip row or column

Mar30
2005
3 Comments Written by admin

To flip the given row as shown in this figure, use the following macro

Flip row or column

Result row

Flip row or column

You can use the same macro for flipping columns too, code will find if it’s a row or a column.

Note: This code was modified on 07/26/07 for error checking, and removal of Option Base

Sub flip()

Dim Arr As Variant
Dim myrange As Range
Dim vSplitedArr As Variant
Dim arRetArr() As Variant, lArrBnd As Long, i As Long

On Error GoTo flip_Error

Set myrange = Range(Selection.Address)
Arr = myrange ‘store the selected values in an array

‘split the selected cells address to an array
vSplitedArr = Split(Selection.Address, “$”)

‘ check if Column names are same
If vSplitedArr(1) = vSplitedArr(3) Then
lArrBnd = UBound(Arr, 1)
ReDim arRetArr(lArrBnd, 0)
For i = 0 To lArrBnd – 1
‘flip the array
arRetArr(i, 0) = Arr(lArrBnd – i, 1)
Next i
Range(Selection.Address) = arRetArr
‘check if Row numbers are same
ElseIf Replace(vSplitedArr(2), “:”, “”) = vSplitedArr(4) Then
lArrBnd = UBound(Arr, 2)
ReDim arRetArr(0, lArrBnd)
For i = 0 To lArrBnd – 1
‘flip the array
arRetArr(0, i) = Arr(1, lArrBnd – i)
Next i
Range(Selection.Address) = arRetArr
Else
MsgBox “Your selection contains multiple rows or columns.” & vbCrLf & _
“This macro will only work on either one column or one row”, vbCritical, “Flip Error”
End If

On Error GoTo 0
SmoothExit_flip:
Exit Sub

flip_Error:
MsgBox “Error ” & Err.Number & ” (” & Err.Description & “) in procedure flip”
Resume SmoothExit_flip
End Sub

Posted in Uncategorized - Tagged excel, flip, VBA

Description of the limitations for working with arrays in Excel 2000, Excel 2002, and Excel 2003

Mar27
2005
Leave a Comment Written by admin

Check the following link, it provides limitations of using array formulas in Excel.

Description of the limitations for working with arrays in Excel 2000, Excel 2002, and Excel 2003

Note The following are helpful facts to remember about the functions.

? If any cells in an array are empty or contain text, MINVERSE returns the #VALUE! error value.

? MINVERSE also returns the #VALUE! error value if the array does not have an equal number of rows and columns.

? MINVERSE returns the #VALUE! error if the returned array exceeds 52 columns by 52 rows.

? The MMULT function returns #VALUE! if the output exceeds 5460 cells.

? The MDETERM function returns #VALUE! if the returned array is larger than 73 rows by 73 columns.

Posted in Uncategorized - Tagged MINVERSE, VALUE

Tags

Access Alt F8 Books boxplot cells charts count cursor dashboard data mining dbase design error excel excel functions export filter flip LaTex MS query Number Err ODBC pipes Press Alt F11 Public Sub python R random numbers Range Cells report scripting software sparklines SQL SQL server stack columns statistics stemming string tag cloud text mining UDF VBA visualization wildcard

Network

View Ashutosh Nandeshwar's profile on LinkedIn

Recent Comments

  • larry on Access Export to Excel (2007)
  • Betty Chou on Projects
  • Rwill on Access Export to Excel (2007)
  • Bharathi on The search key was not found in any record in Access
  • Michael on The search key was not found in any record in Access

EvoLve theme by Blogatize  •  Powered by WordPress nandeshwar.info