Protect your training budget AND save money with our new pre-payment vouchers.

Details for Costas

Costas has participated in the following threads:

Added by Costas on 24 Apr 2017 at 11:26


I was wondering if you could help with the following question. Why the Do Loop stops when it comes accross a value of 0 in a table with integer numbers? How can I handle such a case?

Thanks in advance for the help.


Added by Costas on 03 May 2017 at 16:20


Since I am new in VBA, I would appreciate your assistance. As in your video example, I am trying to loop through each worksheet and each cell in a range of cells by using nested For Each....Next loops. What is wrong with the "SingleWorksheet.ListOfCells" line in the code below?

Sub ForEachSelect()

Dim SingleWorksheet As Worksheet
Dim SingleCell As Range
Dim ListOfCells As Range

Set ListOfCells = Range("a1", Range("a1").End(xlDown))
    For Each SingleWorksheet In Worksheets
        For Each SingleCell In SingleWorksheet.ListOfCells
        Next SingleCell
    Next SingleWorksheet
End Sub


Thanks in advance for the help.

Added by Costas on 25 May 2017 at 18:01


I would appreciate if you could help me with the following code:

Private Sub ComButSave_Click()

Dim NumberOfCells As Long
    Range("A5:OI5").Find(What:=TxtBxMapNumber.Value, MatchCase:=True).Select
    NumberOfCells = Range(ActiveCell, ActiveCell.End(xlDown)).Count
    With ActiveCell
        .Offset(NumberOfCells, 0).Value = ComboBoxNames.Value
        .Offset(NumberOfCells+1, 1).Value = TxtBxDateReturned.Value
    End With
End Sub


The idea is that when I click the Userform button the code: 

1) find's a specific number from a range, 

2) selects the cell where the number is,

3) counts the number of cells between the selected cell and the last cell, and 

4) places specific values to the next cell below the activecell (according to the counted number)

Why my code  has a Run-time Error '1004' (Application defined or Object defined error) when reaches the Offset line of code?

Thank you once more for your valuable help.


Added by Costas on 26 May 2017 at 13:29


I have a Userform with a text box that tries to find a specific number (from 1 to 200) when I press a button. The text box has as property text=1. After seeing the video, I thought for such a search to use the Find method. However even if the line below works with any other number, when I use the number 1 it finds the number 10? I made the same test with numbers 2 & 20 & 200 but there was no problem with them.

Range("A5:OI5").Find(What:=TxtBxMapNumber.Value, LookIn:=xlValues, MatchCase:=True).Select

What is wrong with number 1?  Thanks once more for your assistance.

Added by Costas on 05 Oct 2017 at 08:56


I was wondering, can I apply a property to all selected worksheets when I am in a group mode? For example below the property interior color is applied only to Sheet 1 even if I have selected 2 worksheets. Why is that? 

Sub SelectWorksheetsAndApplyProperty()

    Selection.Range("a1:a5").Interior.Color = rgbBlue
End Sub

Thanks in advance for the answer.


Added by Costas on 29 Aug 2018 at 08:03

Hi, I would appreciate your advice on the following code. It might be very simple but I dont see it. Why it gives me an application or object defined error when I reach the underlined line in the code below?

Dim WS As Integer
    Dim WSCounter As Integer
    Dim WSPV As Long
    Dim SumPV As Long
    Dim Period As Range
    Dim TotalPeriods As Range
    WSCounter = Worksheets.Count - 1
    Set TotalPeriods = Range("A2", Range("A2").End(xlDown))
    For Each Period In TotalPeriods
        For WS = 1 To WSCounter
            WSPV = WorksheetFunction.Sum(Worksheets(WS).Range(Period))
            SumPV = SumPV + WSPV
        Next WS
        Worksheets("Sheet1").Range("A2") = SumPV
    Next Period

Thank you in advance for the help.

Added by Costas on 07 Sep 2018 at 10:21


What can we do If the URL does not include the specific structure to concatenate the parameters and select specific values from a table? For example the URL for Google Finance bellow:

Thanks in advance for the assistance.