BY TOPIC▼
PROGRAMMING BLOGS▼
WRITING VBA BLOGS▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Wise Owl Training - Writing VBA blogs (page 1 of 4)
Showing blogs 1-20 (out of 68)
How to get Excel to read out cell values on calculation
Posted by Andy Brown on 26 September 2016
A short blog explaining how you can get Excel to read out values in cells every time that you recalculate a worksheet.
Referring to a range using square brackets
Posted by Andy Brown on 17 December 2015
This short blog shows that there is a third way to refer to a range, other than using the RANGE or CELLS keywords.
This blog explains the lesser known but better Excel VBA InputBox function
Posted by Andy Brown on 17 December 2015
There are two ways you can display an input box using Excel macros: the standard VBA InputBox function, or the much better (but lesser known, at least by this blog's author) Application.InputBox function.
Disabling Screen Updates in Excel VBA
Posted by Andrew Gould on 26 November 2015
You can give your VBA code a performance boost by simply turning off screen updating while your code runs. This blog explains how to achieve this and how to create a basic timer to test the results.
Installing the Microsoft Date and Time Picker for VBA
Posted by Andrew Gould on 24 February 2015
Some versions of Windows don't include the very useful Date and Time Picker control. This blog explains how to install the mscomct2.ocx file to get it back!
How to insert ActiveX controls after CANNOT INSERT OBJECT message
Posted by Andy Brown on 29 January 2015
When using Excel, we owls have had problems inserting ActiveX objects after recent security updates. Here's a solution which worked for us!
Programmatically searching websites using VBA
Posted by Andy Brown on 19 September 2014
I've already pinched (with permission!) the ideas of Fergus Cairns to explain ways to run automatic searches on popular websites like Google; this blog gives an update on the same topic.
Flappy Bird in Excel VBA Part 13 - Playing Sounds
Posted by Andrew Gould on 24 April 2014
This part of the tutorial explains how to add sounds to the game using a Windows API function.
Flappy Bird in Excel VBA Part 12 - Managing Game State
Posted by Andrew Gould on 24 April 2014
This part of the tutorial implements a state system to make it easier to determine what actions to perform each time the game updates.
Flappy Bird in Excel VBA Part 11 - Detecting Collisions
Posted by Andrew Gould on 24 April 2014
In this part of the tutorial you'll learn how to make the game detect collisions between the bird and the obstacles.
Flappy Bird in Excel VBA Part 10 - Creating Obstacles
Posted by Andrew Gould on 24 April 2014
This part of the tutorial shows you how to add obstacles to the game and how to make them move across the screen.
Flappy Bird in Excel VBA Part 9 - Creating the Game Sheet
Posted by Andrew Gould on 24 April 2014
This part of the tutorial explains how to generate a game worksheet using code to define the playing area.
Flappy Bird in Excel VBA Part 8 - Using Class Modules
Posted by Andrew Gould on 24 April 2014
This part of the tutorial introduces the concept of class modules and shows you how to use them to organise your code.
Flappy Bird in Excel VBA Part 7 - Creating Sprites
Posted by Andrew Gould on 11 April 2014
This part of the tutorial describes how to draw simple images using a worksheet as the canvas. You'll also see how to include the images in the game.
Flappy Bird in Excel VBA Part 6 - Detecting Player Input
Posted by Andrew Gould on 11 April 2014
This part of the tutorial describes how to respond to keys pressed by the player. You'll learn about the Application.OnKey method and the GetAsyncKeyState Windows API function.
Flappy Bird in Excel VBA Part 5 - Starting and Ending the Game
Posted by Andrew Gould on 11 April 2014
This part of the tutorial adds a basic menu system with ActiveX command buttons to start and stop the game.
Flappy Bird in Excel VBA Part 4 - The Game Timing Loop
Posted by Andrew Gould on 11 April 2014
This part of the tutorial describes how to set up a timing loop which allows the game to update continuously.
Flappy Bird in Excel VBA Part 3 - Windows API Functions
Posted by Andrew Gould on 11 April 2014
This part of the tutorial describes how to make use of Windows API functions to extend the power of Excel VBA.
Flappy Bird in Excel VBA Part 2 - Basic Workbook Setup
Posted by Andrew Gould on 11 April 2014
This part of the tutorial describes how to setup a basic workbook ready for you to start coding the Flappy Owl game.
Flappy Bird in Excel VBA Part 1 - Introduction
Posted by Andrew Gould on 11 April 2014
This part of the Flappy Bird in Excel VBA Tutorial introduces you to the Flappy Owl game and provides download links and instructions to get it running in Excel on your machine.
Firstly please let me introduce myself, I'm Charlie, I'm new to coding and I have been given a task. The task is to create code to generate discrete part descriptions for every part number our system can generate. I have attached the code that was written to generate the part numbers, I have also attached the code that I am trying to use to generate the descriptions which has compile error type mismatch occurring.
I would very much like to understand the original code and then create new rather than someone writing the code and just accepting that it works, as has happened before, hence the current situation! My first major hurdle is understanding the "i" in for example:
Dim i1 As Long
If Cells(i2, 2) Mod 2 <> 0 And Cells(i4, 4)
and
Next i5
Amongst other areas of the code.
Sub series325()
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim e As Long
Dim i1 As Long
Dim i2 As Long
Dim i3 As Long
Dim i4 As Long
Dim i5 As Long
Dim counter As Long
counter = 1
a = Range("A1").End(xlDown).Row
b = Range("B1").End(xlDown).Row
c = Range("C1").End(xlDown).Row
d = Range("D1").End(xlDown).Row
e = Range("E1").End(xlDown).Row
For i1 = 2 To a
For i2 = 2 To b
For i3 = 2 To c
For i4 = 2 To d
For i5 = 2 To e
If Cells(i2, 2) Mod 2 <> 0 And Cells(i4, 4) Mod 2 = 0 Then GoTo Nexti
If Cells(i2, 2) Mod 2 <> 0 And Cells(i4, 4) = "-2" Then GoTo Nexti
If Cells(i2, 2) > 61 And Cells(i4, 4) = "-1" Then GoTo Nexti
Cells(counter, 10) = Cells(i1, 1) & Cells(i2, 2) & Cells(i3, 3) & Cells(i4, 4) & Cells(i5, 5)
counter = counter + 1
Nexti:
Next i5
Next i4
Next i3
Next i2
Next i1
End Sub
I would like to apply the same method to the descriptions. I was hoping the code below might work, sadly it didn't.
Sub series325PartDescriptionTest()
Dim a As String
Dim b As Long
Dim c As String
Dim d As String
Dim e As String
Dim f As String
Dim g As String
Dim i1 As String
Dim i2 As Long
Dim i3 As String
Dim i4 As String
Dim i5 As String
Dim i6 As String
Dim i7 As String
Dim counter As String
counter = 1
a = Range("A1").End(xlDown).Row
b = Range("B1").End(xlDown).Row
c = Range("C1").End(xlDown).Row
d = Range("D1").End(xlDown).Row
e = Range("E1").End(xlDown).Row
f = Range("F1").End(xlDown).Row
g = Range("G1").End(xlDown).Row
For i1 = 2 To a
For i2 = 2 To b
For i3 = 2 To c
For i4 = 2 To d
For i5 = 2 To e
For i6 = 2 To f
For i7 = 2 To g
If Cells(i2, 2) Mod 2 <> 0 And Cells(i5, 5) Mod 2 = 0 Then GoTo Nexti
If Cells(i2, 2) Mod 2 <> 0 And Cells(i5, 5) = "Double Row formation. " Then GoTo Nexti
Cells(counter, 10) = Cells(i1, 1) & Cells(i2, 2) & Cells(i3, 3) & Cells(i4, 4) & Cells(i5, 5) & Cells(i6, 6) & Cells(i7, 7)
counter = counter + 1
Nexti:
Next i7
Next i6
Next i5
Next i4
Next i3
Next i2
Next i1
End Sub
I am struggling to add the spreadsheets for reference, the formatting falls apart when I use copy & paste.
Hi Charlie, thanks for your question! It's a tricky one to answer in a simple comment like this one because, as you say, you're new to programming. Fortunately, we've created both written and video tutorials on VBA that will help you to understand all of the elements that go into making up the procedure you're trying to create.
This page lists the written articles that are part of our main Excel VBA tutorial. We've written plenty of other articles on more esoteric aspects of the language but the articles in that tutorial will give the core skills you need.
If you'd prefer to watch rather than read, you can see a list of our Excel VBA videos here. The main ones you'll need in order to understand the code you've posted are the videos on Selecting Cells, Variables in VBA, If Statements in VBA and For Next Loops.
I hope that helps!