Questions tagged [vba7]

Visual Basic for Applications (VBA) is an event-driven, object-oriented programming language for writing macros, used for the MS Office suite as well as other applications. VBA is not equivalent to VBA6, VBA7, VB.NET, or VBS. If your question is specifically about programming any MS Office application, also use the appropriate tag: [excel], [ms-access], [ms-word], [outlook], [powerpoint] or [ms-project].

Visual Basic for Applications (VBA) is an event-driven programming language which was first introduced by Microsoft in 1993 to give Excel 5.0 a more robust object-oriented language for writing macros and automating the use of Excel. The language and its runtime quickly matured and began being used in products beyond Microsoft Office applications.

Differences between VBA 6.0 and VBA 7.0?

There's not a whole lot that has changed between VBA6 and VBA7. VBA7 was introduced to support 64-bit versions of both Office and Windows (see below on what those differences are). Here are the key changes:

  1. 64-bit support, primarily for API calls. This is both used to make your code work with your OS/Office version as well as others' (i.e. someone on Office 2003/WinXP)

    • If you are on a 64-bit version of Windows, but are on a 32-bit version of Office, you can declare API calls like below. .

      #If Win64 Then
          Declare PtrSafe Function GetTickCount64 Lib "kernel32"() As LongLong
      #Else
          Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
      #End If
    • If you are on a 64-bit version of Windows, and are on a 64-bit version of Office, you can declare API calls like: .

      #If VBA7 Then
         Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" ( _
             ByVal lpClassName As String, _
             ByVal lpWindowName As String) As LongPtr
       #Else
         Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _
             lpClassName As String, ByVal lpWindowName As String) As Long
      #End If
  2. To support this, there are:

    • Three new keywords (2 data types and 1 modifier): LongPtr, LongLong and PtrSafe

    • One new function: CLngLng() (i.e. Int64)

    • The new compilation constants as used above: VBA7 and Win64

Reference

Differences between VBA 6.0 and VBA 7.0

308 questions
1
vote
1 answer

Customize the Value displayed in the VBA Watch Window for Custom Classes

I'm working in VBA (specifically, Microsoft Access VBA). I've written several custom VBA classes, and I'm using the VBE's Watch Window to see values during debugging. I'd like to create a function similar to ToString() in .NET languages that will…
Pflugs
  • 772
  • 1
  • 10
  • 18
1
vote
1 answer

Excel chart as ole object in access form doesn't update properly

I have an access form where I have included an excel chart as an unbound ole object. (MS Graphs in access are so terrible!) The excel sheet is an independent file, outside the database. Through a DoCmd.TransferSpreadsheet instruction I can export…
1
vote
1 answer

Count specific shapes on Excel by VBA

I developed Excel VBA code to appear the shapes and count them by categories depending on data entry. For example: Until now the shapes are appeared based on data entry. I can't count the shapes by categories. An example of what I need: My…
Reda
  • 449
  • 1
  • 4
  • 17
1
vote
2 answers

How to get text from wrapped text show on different columns using VBA

I have a vba script that copies and paste data from one workbook to the other. The data that is being pasted over are wrapped text. I need my vba script to take the wrapped text and turn it to what you see below. Below is the data that is being…
1
vote
1 answer

VBA MsgBox reformats dd/mm/yyyy Format output to dd-mm-yyyy

Very new to VBA. I guess MsgBox debugging is the VBA equivalent to print statement debugging in other languages? If I use Format to turn a date into a string using dd/mm/yyyy format, and then print that string with a MsgBox, it instead prints in…
Jack Deeth
  • 3,062
  • 3
  • 24
  • 39
1
vote
2 answers

Delete entire rows according to many values

I have a long excel file, from which I need to delete entire rows that contain certain values in the column A. The column contains values from [PAR001 to PAR0023247] and I need to delete the ones that fall within [PAR002537 To PAR005214] Which is…
1
vote
0 answers

if a specific word found in a cell then copy the row to another sheet

is there a way to look for specific word in cells even if it's within more text i've been trying below but it only works if the only data exsits within a cell is the word. Sub Tucana() Dim sh1 As Worksheet, sh2 As Worksheet, rng As Range, cel As…
DesTro
  • 9
  • 5
1
vote
2 answers

VBA call macro to split cells when cell changes

Trying to make a macro that automatically calls another macro to extract parts of the entered string and insert into two other cells. The splitting macro works when called on a cell manually but cannot get it to trigger automatically. Sub…
1
vote
1 answer

If two cells match, return value from third in the same row irrespective of the order in excel

I have a table as follows: |**Corresponding Values**| |:.......|:.....:|......:| | O1 | F1 | S1 | | O2 | F2 | S2 | | O3 | F3 | S3 | | O4 | F4 | S4 | | O5 | F5 | S5 | | O6 | F6 | S6 | | O7…
1
vote
1 answer

Populate a Cell with another cell's value in a single click

I'm new with VB coding in Excel and would like to know how if I can click on a particular cell and have that cell loaded with the value of another cell with a single click. For example, if the value “SVE” is in cell AP1, how can I click on the blank…
Tony Woods
  • 13
  • 3
1
vote
1 answer

Checking two lists of emails for duplicates, returning "yes", "no", or ""

I'm trying to design a sheet to be used within a team, so there would be fields that have new data entered regularly. Goal: check for the cell contacts (E2) against a range of cells for exact matches (A2:A), in F2 (where formula would be entered)…
Lauren
  • 25
  • 3
1
vote
1 answer

Filter worksheet with 2 sets of data and copy some columns into new worksheet

I got help with the code below. I have a worksheet with 2 sets of data. Each data set has its own headers. My intentions: Filter the first data set (only) using InputBox and copy multiple columns ("A:A, C:C, E:F, U:W, Y:Z, AB:AC") into another…
Kthom
  • 13
  • 6
1
vote
5 answers

How to sort outline numbers in "numerical" order?

For instance, I would like these 6 numbers. Currently when I use the sort method it puts 6.6.1.1.13 first and 6.6.1.1.2 later. Before Sort 6.6.1.1 6.6.1.1.1 6.6.1.1.13 6.6.11.14 ► 6.6.1.1.2 What I Want It To Look Like After Sort 6.6.1.1 …
Punar
  • 21
  • 4
1
vote
1 answer

Standardizing date format when moving code to different machines in MS Access

Good day everyone, I have a MS Access function that I was using on a machine using the mm/dd/yyyy format but now have moved to a machine using the dd/mm/yyyy format. Public Function fncERates(sEID As Long, PeriodEnd As Date) As Double Dim strERates…
1
vote
1 answer

How to insert whole columns (Key Value) in Scripting.Dictionary using VBA Macro in Excel Sheet?

I want to select the unique Key Value pair from the 2 different whole column and insert the data into "Scripting.Dictionary" using VBA Code. I have used before List() but I need the key value pair for search and replace the string by loop through…
skt
  • 449
  • 14
  • 32
1 2
3
20 21