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

Access to the VB project is not trusted

Apr24
2009
2 Comments Written by admin

I was trying to enable an add-in for Excel 2007, and I kept getting this error:

Access to the VB project is not trusted

You can turn this message off by going to Developer tab in the ribbon and then clicking on the Macro security button, and checking the check box for “Trust access to the VBA project object model.”

A word of caution: be wary of the add-ins/projects that need VBA access. Don’t allow any project/add-in with VBA access, unless you know its exact purpose or the author of that project.

Posted in Error messages - Tagged error, excel, VBA

Count Text in a Range

Apr24
2009
Leave a Comment Written by admin

Counting text in a range is easy. For example, if you would like count how many times “text” is in a specified range (named data), you can write something like this:
=COUNTIF(data,"*text*")

This formula will give you the count of all the cells where Excel found “text” at any place.

But let’s say you want to count wildcard characters in a range, then you can write something like this:
=SUM(IF(NOT(ISERR(FIND("*",data))),1,0))

This formula should be entered as an array formula with Ctrl + Shift + Enter. Usually, wildcard can be “escaped” using a tilde (~), but the FIND function doesn’t understand wildcard characters like the SEARCH function does.

Posted in String Operations - Tagged count, excel functions, string, wildcard

The data on the Clipboard is damaged, so Microsoft Office Access can’t paste it.

Apr06
2009
6 Comments Written by admin

This is a new one for me. One good thing working with Excel and Access is the Copy/Paste ease between them. I usually paste data from Excel to Access for these two reasons:

  1. Create tables in Access (for small tables)
  2. Paste Field names: either in a table or in the import specs form

When I am importing data of the web, usually they have field names and data types given that page, so it makes sense to import that table in Excel (using Import from Web option), and then copy the field names and directly paste them the import specs form in Access. However, I kept running in this error today, which MS acknowledged and provided a solution, caused due to a security patch.

I used a workaround to paste those field names: copy and paste the data in a text file, and the again copy and paste it in Excel.

Solution Update: Colleen provided one more MS KB number to fix this problem. So, there are two KB articles which acknowledge this problem:

KB967699: http://support.microsoft.com/kb/967699

KB958437: http://support.microsoft.com/kb/958437

Posted in Error messages - Tagged Access

Access Export to Excel (2007)

Mar02
2009
13 Comments Written by admin

When I tried to export a table/query from Access 2007 to Excel 2007, I was getting this annoying error:

You selected more records than can be copied onto the Clipboard at one time. Divide the records into two or more groups, and then copy and paste one group at a time. The maximum number of records you can paste at one time is approximately 65,000.

Access 2007 Export to Excel Error

Access 2007 Export to Excel Error

I was unable to understand the reason, because I thought Excel 2007 did not limit number of rows to 65,536. It turns out however that it is the clipboard limitation.

Solution: If you check off the “export data with formatting and layout” option, Access exports successfully.

You can export successfully using Transferspreadsheet (VBA) option too.

Here is the KB from MS.

Solution Update:Thanks to Brett, it looks like that only if you export table/query using right click > Export and have the checkbox cleared, then Access will export succesfully. That is what I always do, and it works for me. I have never tried External data option for exporting.

Posted in Access, Error messages - Tagged Access, error, export

Create Sheets based on a Column

Nov10
2008
Leave a Comment Written by admin

Ever felt the need of creating different sheets based on the distinct values of a column. For example, in your data, you have a column called STATE, and you would like to create a separate sheet for each state with all the data from that state. Here’s your solution then:
(Note: you’ll need to add a UDF function UniqueItems from http://j-walk.com/ss/excel/tips/tip15.htm)

This procedure will create a new sheet for each unique item in the selected column with the data from the main sheet for that unique item. As an added bonus, the procedure will sort the sheets ascending (Courtesy:ozgrid.com)
‘—————————————————————————————
‘ Procedure : CreateSheetsColumn
‘ DateTime  : 11/10/2008 09:32
‘ Author    : ARN
‘ Purpose   : To create sheets with the data from the main sheet based on a selected column.
‘Assumptions:
    ’1 -  data are in contigious form
    ’2 – the unique column does not have any special characters
    ’3 – the first row is the header row
    ’4 – the only sheet in the workbook is the data workbook
‘—————————————————————————————
‘
Public Sub CreateSheetsColumn()

On Error GoTo CreateSheetsColumn_Error
    Dim rngInput As Range, rngColAddr As Range, varrUniqueVals() As Variant, dCounter As Double
    Dim rngCol As Range
    Dim dUniqueItems As Double, dColtoFilterOn As Double
    
    Dim lCount As Long, lShtLast As Long, lCount2 As Long
    
    ‘Set the working range
    Set rngInput = ActiveSheet.Range(Cells(1, 1), Cells(1, 1).SpecialCells(xlLastCell))
                                    
    ‘get the column to work on from the user
    Set rngColAddr = Application.InputBox(prompt:=”Select the column that would be used to create distinct sheets”, _
                                    Title:=”Select a Column”, _
                                    Type:=8)
    ‘if more than one column is selected, exit
    If rngColAddr.Columns.Count > 1 Then
        MsgBox “Too many columns; select only one column”, vbOKOnly
        Exit Sub
    End If
    
    ‘set the application screen updating to false to increase execution speed
    Application.ScreenUpdating = False
    
    ‘store the column number in a variable
    dColtoFilterOn = rngColAddr.Column
    
    ‘set a range from the 2nd row to the last row from the selected column to get the distinct values
    Set rngCol = ActiveSheet.Range(Cells(2, dColtoFilterOn), Cells(rngInput.Rows.Count, dColtoFilterOn))
    
    ‘use the function UniqueItems (http://j-walk.com/ss/excel/tips/tip15.htm) to get unique values from the selected column
    varrUniqueVals = UniqueItems(rngCol, False)
    
    ‘get the total number of unique items
    dUniqueItems = UBound(varrUniqueVals, 1)
    
    ‘start a loop to filter the range on each unique item
    For dCounter = 1 To dUniqueItems
        ‘ only if the unique value is not blank
        If Not varrUniqueVals(dCounter) = “” Then
            ‘ apply filter
            rngInput.AutoFilter Field:=dColtoFilterOn, Criteria1:=varrUniqueVals(dCounter)
            
            ‘add a new sheet
            Sheets.Add After:=Sheets(Sheets.Count)
            
            ‘rename the sheet
            ActiveSheet.Name = varrUniqueVals(dCounter)
            
             >‘copy the filtered data
            rngInput.Copy Destination:=Worksheets(varrUniqueVals(dCounter)).Range(“A1″)
            
            ‘remove copy
            Application.CutCopyMode = False
        End If
    Next dCounter
    
    ‘remove filter
    rngInput.AutoFilter
    
    
    ‘ Sort sheets ascending – except the first one
    ‘ copied from http://www.ozgrid.com/VBA/sort-sheets.htm
    
    lShtLast = Sheets.Count
    For lCount = 2 To lShtLast
            For lCount2 = lCount To lShtLast
                If UCase(Sheets(lCount2).Name) < UCase(Sheets(lCount).Name) Then
                    Sheets(lCount2).Move Before:=Sheets(lCount)
                End If
            Next lCount2
        Next lCount
        
MsgBox “Done”

On Error GoTo 0
SmoothExit_CreateSheetsColumn:

    Application.ScreenUpdating = True

    Exit Sub

CreateSheetsColumn_Error:
    MsgBox “Error ” & Err.Number & ” (” & Err.Description & “) in Sub:CreateSheetsColumn”
    Resume SmoothExit_CreateSheetsColumn
End Sub

Posted in Uncategorized - Tagged Create Sheets, excel, filter, Range Cells
« Older Entries Newer Entries »

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