Stack Overflow Community » VBA
109 FOLLOWERS
Stack Overflow is a public platform building the definitive collection of coding questions & answers. This community is a place to get all your queries solved regarding VBA, an event-driven, object-oriented programming language for writing macros
Stack Overflow Community » VBA
4h ago
i have 2 modules in 2 forms in my program in VBA excel for my assignment in my subject. i literally dont know how to connect a module into a form pls help
i was trying to assign a module in form where form1 is assigned in module1 while form2 is assigned in module 2 but when i try to run it it does not run ..read more
Stack Overflow Community » VBA
5h ago
I have about 20,000 csv files of historical price data, 12 columns, and need to batch process it daily. Individual files are typically small (<1000k), but in total it is 4GB of data.
What is the absolute fastest way to programmatically access the data in Excel with VBA? I only need to process a file, the result being stored in Excel, then I don't need to use the specific file again. And I only have to review a certain time frame subset within the file, never the full history in each file.
It's too large for a single MS Access db. PoweQuery? Import each file as needed via delimiter, or open ..read more
Stack Overflow Community » VBA
9h ago
I'm trying to create a script that Outlook for the required text in the body of the letter, for example, "order-33", if found, then look in the attachment (DOC and PDF files) look for the order number (order number 12345, the words order number are always in attachment, but the numbers are always different), then save the attachment in the folder c:\temp, giving it a name that consists of the found order number. In this case, the DOC-file must be saved as PDF. Below is the code that only saves the attachment to the folder.
Sub SAVE_ATT (item As Outlook.MailItem)
Dim objAtt As Outlook.Attachme ..read more
Stack Overflow Community » VBA
11h ago
I am creating a database, and I want to generate a UniqueReference for each entry - the format is YY-0000. In the form, I have put a button with the following code, but it coming up with an syntax error and I can't work out how to fix it.
Private Sub Command39_Click()
Dim vLast As Variant
Dim iNext As Integer
vLast = DMax("[UniqueReference]", "[ScammerInfo]", "[UniqueReference]" & Format([DateCreated], "yy\*\'"))
If IsNull(vLast) Then
iNext = 1
Else
iNext = Val(Right(vLast, 4)) + 1
End If
Me![UniqueReference] = Format([txtDateCreated], "yy") & "-" & Format(Next, "0000 ..read more
Stack Overflow Community » VBA
14h ago
I want to use this code:
Dim dblWidth As Double
Dim dblHeight As Double
dblWidth = Selection.Width
dblHeight = Selection.Height
'Points
TextBox1 = dblWidth
TextBox2 = dblHeight
'Inches
TextBox3 = dblWidth / 72
TextBox4 = dblHeight / 72
'cm
TextBox5 = dblWidth / 28.35
TextBox6 = dblHeight / 28.35
'mm
TextBox7 = TextBox5.Value * 10
TextBox8 = TextBox6.Value * 10
End Sub
to show selected range overall width and height in various Units on a userform. The problem is that the showing values, for example 'cm', on the userform doesn't seems to be right.
For example when I select a cell and man ..read more
Stack Overflow Community » VBA
16h ago
I'm using below code to read and manipulate the Merge Fields but it is not getting the merge fields from textbox used in the word document, I am using excel VBA to read the word document.
I tried by using doc.shapes to get the textbox but could not get he items from text box
Could not find any resource for this.
For Each fld In .Fields
Debug.Print ("-" & fld.Code.Text)
Next ..read more
Stack Overflow Community » VBA
17h ago
If I have the Seven Dwarfs names as strings in cells H1 to N1 and then select cells B1 to B7, then insert the formula =TRANSPOSE(H1:N1) and then Ctrl-Shift-Enter, then the Seven Dwarfs are inserted into the B column as expected.
However, if I try the same thing using VBA as below:
Then I get run-time error '1004': Method 'Range' of object '_Global' failed.
Option Explicit
Option Base 1
Sub TransposeArray()
Dim A() As Variant
Dim nr As Integer
nr = 7
ReDim A(nr) As Variant
A(1) = "Doc"
A(2) = "Grumpy"
A(3) = "Happy"
A(4) = "Sleepy"
A(5) = "Bashful"
A(6) = "Sneezy"
A(7) = "Dopey"
' this line ..read more
Stack Overflow Community » VBA
18h ago
Requesting a VBA code for creating a macro that allows to automatically paste in transpose mode in a selected cell and delete the selected rows that have been copied.
The data is in the following manner
Ana I want the data ..read more
Stack Overflow Community » VBA
19h ago
enter image description here
When a button is clicked, an inputbox will load for the user to enter a string. The inputbox will reappear for a new input unitl "!" is entered. Right now, I have each input stored in a listbox but I want every input to be stored in an array. How can can I do this?
I tried using reDim but that doesn't seem to work ..read more
Stack Overflow Community » VBA
21h ago
I'm Trying the change the mailmerge field names dynamically in VBA, I created this code but it removes the fields or its not working properly, could not find a solution.
Here I used columnMapping dictionary to keep the new headers.
Actual problem is the mapped DB have different column names hence I'm trying to replace the field names dynamically.
Edit: updated the code
Set columnMapping = CreateObject("Scripting.Dictionary")
columnMapping("Header1") = "New_Header"
For Each fld In doc.MailMerge.Fields
Debug.Print (fld)
Dim oldName As String
Dim newName As String ..read more