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
0
votes
1 answer

VBA - Split row by quantity by values

I am currently trying to split up a row by its quantity then update the "picked" value to reflect this, For example Product A has a QTY of 5, so 5 lines should be created. Only 3 of these have been picked, so the first 3 new lines can have a picked…
Joe
  • 1
  • 1
0
votes
0 answers

Text To Columns isn't working in my vba script

I am trying to get my Text To Columns to work in my VBA script, but it's not working for me. I understand how it works in excel and even used the macro record to get it working, but when adding it to my script nothing happens. I even looked at…
0
votes
1 answer

Data being extracted from wrapped text not going to next column cell after complete in vba

I managed to extract data from a wrapped cell from a workbook and sending that data to another workbook. The wrapped cell has text going line by line and I'm using split text to iterate through each one to get the data I want. The problem is after…
0
votes
1 answer

VBA No Cells are found

I used this yesterday and it ran fine but today I got a error "Run-time error '1004': No cells were found. It bugs at Range("A6:A30").SpecialCells(xlCellTypeVisible).Find("Temp").Select Attached Macro Below Sub HrsInput() ' Disable screen…
Kim
  • 31
  • 5
0
votes
1 answer

Rearrange columns as per column headers - Run-time error 9: Subscript out of range

I want to rearrange columns as per column headers. I found the below macro on this platform. I get the error at this line code. If cel.value=correctOrder(col - 1) Then This is the error "Run-time error '9': Subscript out of range Sub…
Bash
  • 3
  • 2
0
votes
0 answers

VBA script that opens windows explorer and points to a file that copies values from one workbook to another

I have a VBA script that copies and paste data from one workbook to another, but I would like to get my script so when I click run, windows explorer window opens up and I select the file that has the data in it. It takes that data and copies and…
0
votes
1 answer

VBA code in excel to copy a field and paste into a new outlook email

I currently have a vba code that is activated by a button in excel that copies certain information from the sheet into an outlook email. Having updated to win64 and updating the declare statements etc. I can not get it to open an outlook email…
0
votes
2 answers

I have a Product Name like this. I run vba code for extracting date, am not getting the result, it shows error

Code: Sub My_Date() Dim endRow As Long endRow = Cells(rows.Count, "B").End(xlUp).row ActiveCell.FormulaR1C1 = _ …
Karthik
  • 11
  • 2
0
votes
1 answer

Custom lookup using search in VBA

I am not sure, how to fix this function. if Isnumber(search) is true, then get value from lookup_table after 2nd round, it ends Image of excel data Function Slookup(lookup_value As String, lookup_table As Range) As String Dim i As Integer On Error…
KrazyAC
  • 13
  • 3
0
votes
0 answers

"getElementById from website shows error"

I created the following program to extract data from website to excel sheet but it's showing error. Error line: price = html.getElementById("azimuth").Item(0).innerText" Error message: Run Time Error '91': with Object Variable or block variable…
0
votes
0 answers

Code not running on load event in MS access

I can get the following code to run manually on a button but it will not do anything when put into the on load event of the form. I'm sure I'm missing something obvious but can't see what it is! "newenquirysiteslistq" is a query of address's based…
Ming
  • 1
0
votes
0 answers

VBA misaligned OptionButtons using VBA

Picture below, you will see the issue immediately. I wanted to ask, if somebody can tell me where my mistake is. I try to generate Option Buttons aligned to cells. To do that I set ranges and tell excel to create an OptionButton for every cell in a…
0
votes
1 answer

How do I copy column width and conditional formatting to an active sheet?

I have two sheets Projects ( where I will store project names) and Template (where new projects will be created using the "template" sheet) I have two issues: How do I copy the format on an active sheet including conditional formatting and column…
user407362
  • 23
  • 4
0
votes
1 answer

Can I compile old Excel COM Add-in code written in VB6.0 to work in 64-bit Excel?

I have code for an excel add-in I wrote over 20 years ago that I find myself needing again. It works fine in Windows XP and Excel 2003 in a virtualbox. In the VB6.0 IDE, I can load the code and make the dll which I can register as an excel add-in…
snowguy
  • 899
  • 2
  • 13
  • 23
0
votes
1 answer

Excel Macro to perform a formula where one column has the same value in several rows

I can't quite find the right code example to do what I'm looking to do. We have an excel file with data from a project where a request can have several TASKs associated with it and different teams or organizations can be assigned. I'm trying to…