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

Add the sum of the total amount from the sheet

Thanks for opening my thread. I need help from you. So in this sheet the total amount should be sum of fuel + surge + delivery_charge should be added in Total amount column. Ex:- 1st order = 456777 this should add 109.49+303.41+25966.51 =…
Ranger
  • 5
  • 2
0
votes
2 answers

Remove all formatting when copy and pasting with Word

In word there is the ability to Edit > Paste Special > Unformatted Text, and I'd like to do this by default. I've created a Macro that reads: Selection.Collapse Direction:=wdCollapseStart Selection.PasteSpecial DataType:=wdPasteText Which seems…
0
votes
0 answers

How to conditional copy unique values only?

I want to copy unique values over to my destination worksheet but I'm getting an error with my Range. Originally I wrote a RemoveDuplicates code with exact same Range values and it worked perfectly fine. I'm assuming the issue is in my…
vliwei4
  • 1
  • 1
0
votes
0 answers

VBA - IFELSE and Continuous Looping

I want to have 2 formulas with continuous looping as long as there is value in the cell next to the targeted cell, thus i need to have ifelse function but with continuous looping aswell. for now i don't know how to insert the second…
0
votes
0 answers

listbox vba : listcount doesn't update immediately

Hello everyone and thanks in advance for the help. Shortly: I have a textbox used to input a name to search. According to this "name", A listbox update with all the record found from a table (and following, cliking on the listbox I update a…
0
votes
1 answer

Loop index confusion

I am attempting to add the values from any twelve consecutive sheets in an external workbook that are in the same cell reference by creating an array that is filled with the values in said cell reference for all sheets in the workbook. Then, using a…
Gcodes
  • 3
  • 3
0
votes
0 answers

Run-time error '9': Subscript out of range for a set workbook statement

When trying to run the following code in vba, I keep getting a runtime error stating "subscript out of range". Upon debugging, it appears the error is in this line: Set wkbRef = Excel.Workbooks("FileName.xlsx"). I do not know what subscript the…
Gcodes
  • 3
  • 3
0
votes
1 answer

Freeze on specific sheet during macro execution and loop through each sheet containing a specific name

The parts not working are especially loop parts (marked as --- not working ---). Do I have to “activate” them first somehow? The part which displays sheet “X” and freezing the screen isn't working too. I want to display a picture on sheet “X” with a…
0
votes
1 answer

vba loop to add 12 consecutive months worth of data

I am attempting to create vba code to add the values of twelve consecutive months of data to a cell, then increment each month to be added by one, so that the code shifts to sum 12 months that include the newer month of data. For example, the first…
Gcodes
  • 3
  • 3
0
votes
0 answers

Workbook.Activate not working after selection of Range

I wrote a simple VBA code to automate writing of Vlookup formulas. After testing the code I noticed that it is not working correctly when I select a Range from a different workbook. It creates Vlookup formula as intented but it does not switch to…
0
votes
0 answers

Prompting/Displaying a Filter box for a specific column

I need a code which selects the column and displays the Filter box as shown in the below image("This is a filter dropdown which allows us to select the list of values"). I want a code which follows the following steps Select column A Prompts us the…
0
votes
0 answers

SUMIF indirect excel

I am working to create a formula that adds the value of cell K207 on 12 different sheets and stores it in a cell. I have created the following…
Gcodes
  • 3
  • 3
0
votes
1 answer

Why is my excel Chart not going to a new workbook in VBA

I have a excel workbook that has values in them. I'm taking those values and creating a Chart with it using VBA. The chart is then saved to a worksheet on the same excel sheet as the values. I need the Chart to be moved to a different workbook. What…
0
votes
0 answers

No cells found - excel

I get a error that no cells are found and it highlights Range("A6:A109").SpecialCells(xlCellTypeVisible).Find("Temp").Select When I open the file it looks like this below and column F is hidden and that's where my value is. How and where can I add…
Kim
  • 31
  • 5
0
votes
1 answer

Created Custom Formula is showing @ why?

Formula is showing @ symbol. why it is showing. and how can i solve it.
Srinivas Ch
  • 1,202
  • 2
  • 19
  • 34