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

Inserting data from text file in respective excel columns

Many Many thanks in advance I have a .txt file that contains data that needs to be extracted and placed into respective columns in Excel. I am very much new to VBA coding and tried a lot, but having difficulty in making this work... below shows the…
user12446614
0
votes
1 answer

Txt file close around 10000 lines of input

I have written txt-files with excel and a macro in the past several times. I didn't hit 10000 lines or more. Never say Never... My .csv file has over 87000 rows like that example "15k50,CityABC,56ab,CountryofCity,ID,Street". I use the Split()…
0
votes
1 answer

How to distribute a known number evenly across a range in VBA

I've a problem here, I've been trying to use VBA to distribute a known number evenly across a range.The problem is that I need to find the way where the numbers in the range be as equal as possible to each other, could you help me? or give…
Xkid
  • 338
  • 1
  • 4
  • 17
0
votes
1 answer

MS Excel: I need to create a custom formula in which if BOTH conditions are met, then the output = 1, otherwise output = 0

Condition 1: Cell A1 should not be empty Condition 2: The interior colour of cell A1 is a specific colour. In this case its specifically "light green" If both of these conditions are met, then the out should be 1. If one or both conditions aren't…
0
votes
1 answer

How to set element id based on cell content in VBA?

I'm working on a little project which would allow me to pull some searches directly from a website without actually opening the webpage. To get to the end of it, I need my VBA code to automatically open a drop-down list which contains some elements…
0
votes
1 answer

Relative references, recoaring macro, VBA

I am recording a macro in VBA using relative references, I first select cell A1. The code that is generated is this: ActiveCell.FormulaR1C1 = "First Cell" ActiveCell.Offset(1,1).Range("A1").Select ActiveCell.FormulaR1C1 = "Second Cell" …
arnis
  • 13
  • 3
0
votes
0 answers

Why does the copycolumn() custom button does not copy all the column but just the last one

I ran into a problem while trying to write a VBA code to copy the content of a column to another sheet in the same project. The problem is that instead of copying the entire columns' data it only copies the last row's data. This is the VBA code I…
0
votes
0 answers

Get Application name from process name. Required in 64bit

I found a code which would help one of my projects. However I can't use it in my 64bit MS Access. This was the original post How to get Application name from process name? Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As…
0
votes
0 answers

URL to download a csv file using excel vba

Is there any way I can download the csv file from below link for example. "https://www.nseindia.com/corporates-pit?index=equities&symbol=WABCOINDIA&csv=true" Tried the below code but no luck. Private Declare PtrSafe Function URLDownloadToFile Lib…
Kiran
  • 167
  • 1
  • 9
0
votes
2 answers

Returning matches in column in VBA

So I have the following data set from a worksheet: +---------+-------------+-----------+ | Account | Type | Value | +---------+-------------+-----------+ | XX | iPhone | 123 | | XX | Samsung | 567 | | XX …
m.barros
  • 33
  • 5
0
votes
1 answer

Collection of Collections - Refer to SubCollection Item with Variable for Primary Collection

I’m using (as example) a UserForm with six TextBoxes on a 3x2 matrix: like this: c1 c2 c3 c4 c5 c6 I’m trying to add both of these Rows of TextBoxes to a Collection (secondary) and then add this Collections to a Collection (primary) of…
Artemis
  • 5
  • 3
0
votes
1 answer

Array Calculation Order Problem - Why I can't emulate something easily done in excel?

I am trying to emulate something I have done easily in Excel in a VBA array, but I can't get it to run. I think it has to do with the nature of the calculation which depends on the order in which the rows are calculated. I will attach an excel…
joshuad
  • 41
  • 6
0
votes
1 answer

VBA Find .address sometimes returns range and other times a cell

I'm having an issue with the VBA Range.Find method. What the code is doing is looking through all of the worksheets in a workbook, find any matches to data in an array, and change the color of the cell with the same value as that data. The code…
0
votes
2 answers

Scripting.Dictionary to fill a column with a string taking in consideration more then 3 criteria

I am trying to fill a column C with the string consider if the consumer on the row matches one of the criteria: If the consumer meets one of these rules, the value should be set to Consider: • Consumer has only 1 Transaction -- (is done) • Consumer…
Fah
  • 207
  • 3
  • 16
0
votes
1 answer

how to set values between worksheets after IF statement using 2 last rows

I am trying to copy and paste the entire entire columns values from sheet named Hey, to another columns in a sheet named final. I dont want to use copy, paste or select option.However, my code is copying only the 1st line. IntLastRow =…
Fah
  • 207
  • 3
  • 16