Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
545 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Hi there,
I tried to do the same as what you have here on your tutorial. I just cannot find out why on the calculation of time lengths for the movies, the last row of result is showing #N/A error for me.
The file is here: https://www.dropbox.com/s/kl6yonheorqocm6/VBA%20Arrays%20sample%20with%20calculation.xlsm?dl=0
Can you please check my code?
Option Explicit
Sub CalculateWithArray()
Dim FilmLengths() As Variant
Dim Answers() As Variant
Dim Dimension1 As Long, Counter As Long
Sheet1.Activate
Range("f3", Range("g3").End(xlDown)).ClearContents
' Assign values of range D to the array FilmLengths
FilmLengths = Range("d3", Range("d3").End(xlDown))
' Assign the number of values of array FilmLengths to the variable Dimension1
Dimension1 = UBound(FilmLengths, 1)
' Resize the dimensions of array Answers according to the number of values of Array FilmLenghts and add 2nd column or dimension
ReDim Answers(1 To Dimension1, 1 To 2)
' Loop over the FilmLengths and return Answers as number of hours and remainder in minutes
For Counter = 1 To Dimension1
Answers(Counter, 1) = Int(FilmLengths(Counter, 1) / 60)
Answers(Counter, 2) = FilmLengths(Counter, 1) Mod 60
Next Counter
' Populate columns F and G with the Answers
Range("f3", Range("f3").Offset(Counter - 1, 1)) = Answers
Erase FilmLengths
Erase Answers
End Sub
Thank you and regards,
Ryan
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.