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
2 answers

How to end the loop is the variable is empty

Sub max() Sheets(1).Select Sheets(1).Name = "Sheet1" Dim rng As Range Dim celladdress As String Dim celling As Variant Do Until IsEmpty(celling) If celling > "G4" Then Set rng = Range("G3:G1000").Find(what:="Description") …
0
votes
3 answers

Determining the cell address to know where my loop ends - EXCEL VBA

Hi I am wondering how to use .address to determine on what row should I stop in my iteration. So my code is finding the cell address of a predetermined row of dates (weekly) and when I input a date, it will automatically look for the match/closest…
0
votes
2 answers

Column not offsetting

Sub Delete_Columns() Dim Last_Row As Integer Dim rnge As Range Dim celladdres As Variant Dim v As Integer Last_Row = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row Cells(Last_Row, [13]).Value =…
0
votes
1 answer

How do i use Dlookup for Multiple Criteria to create a dynamic Combobox

I have two Comboboxes on a from: txtKategorie and txtTyp. The values for the frist Combobox (txtKategorie) are fix! I want the values of the second Combobox (txtTyp) to change according to what the user chooses in the first one. If the user chooses…
forRnB
  • 15
  • 6
0
votes
1 answer

How to setup VBA IDE with multi-tab code windows view

I'm looking for a workaround to allow the IDE of VBA7 (ms-access 2010) to organize multiple code windows in tabs (multi-tab view), like in most modern code editors. Do anyone of you guys out there knows a settings or a method to achieve this…
PietroV
  • 1
  • 2
0
votes
1 answer

Progress bar using VBA

I'm working on excel sheet using VBA: I'm trying to test a progress bar. I already completed the design, as shown below: Below the userForm code: 'PLACE IN YOUR USERFORM CODE Private Sub UserForm_Initialize() #If IsMac = False Then 'hide the…
lagna
  • 3
  • 1
  • 5
0
votes
1 answer

Send email with text based on cell values to each student using VBA

I'm trying to send an email to each student (that contain the student name and marks) using VBA. I have an Excel sheet as below: I need to send an email to each student with email body text as below: Hi " Student name " Below you can found your…
Tariq
  • 101
  • 1
  • 1
  • 10
0
votes
1 answer

Sometimes when I run the code it works, other times I get Run-Error '1004' and I don't know why?

First of all I'm a beginner with VBA so I don't understand a lot. I tend to record my macros and then slightly modify them. I get the following Error 1004 message You can't paste this here because the Copy Area and paste area aren't the same size.…
0
votes
0 answers

ThisOutlookSession Public WithEvents variables stopped being public

I use event handlers to automatically sort email in Outlook 2016. Those event handlers have been defined in ThisOutlookSession as Public WithEvents variables, they are set using the Application_Startup event, and they call different procedures…
BenN
  • 1
  • 1
0
votes
1 answer

Delete n% of the rows from the excel sheet on click of the button using VBA or any excel formula if possible

I want to delete the n% of the cells from the sheet1,sheet2,sheet3,sheet4. The percentage will be given in the sheet name as raw. For example in raw sheet in E19 its given 10%, so in every sheet S1,S2,S3,S4 it should delete the total of 10% of the…
0
votes
1 answer

Need to add UID for the data set in the excel sheet

I have a dataset and that have the values in B and C columns. I need to add the UID for every instances of data present in the B column. Example. The column A should give me the UID for data set based on the data present in the column B. I have…
0
votes
1 answer

Print specific data with Json perse

This is json code (https://textsaver.flap.tv/lists/3ic4) and i am trying Sub test() Dim req As New MSXML2.XMLHTTP60 Dim URL As String, ws As Worksheet Dim json As Object, r, r1 As String URL =…
AAdi
  • 15
  • 4
0
votes
1 answer

Error 31 - Calling CredUIPromptForWindowsCredentialW from VBA macro

I recently asked this question but deleted due to insufficient information. I will attempt to ask it again hopefully with more information. I am trying to call the Win32 API function CredUIPromptForWindowsCredentialsW() but have been failing for the…
m57
  • 1
  • 4
0
votes
0 answers

Excel 2016 64bit VBA: Why does my global variable reset at end of sub?

I need to store a date as a global variable. I thought I was doing this but the watch shows it resetting after the sub ends. I've looked at countless global variable articles and responses to questions, nothing seemed to work. So, just how do I stop…
0
votes
2 answers

Declare statement in Win64 VBA Office

I have used vba code in Windows 32 bit. Now that I've migrated to Windows 10 64 bit I got the message "The code in this project should be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with PtrSafe…
Julio Garcia
  • 1
  • 1
  • 3