Q:

Using Left() for variable

I'm new to VBA.
So i was trying to append prefixes to a set of values, depending on the first number of each value. 
However i get a Type mismatch error on line 4. I suppose it is because I am trying to use Left() on a variable, and it is supposed to be used on a string (or something of that sorts?)
How do i accomplish that?
Thank you in advance
Sub test()
a = UsedRange.Rows.Count
Testvariable = Range("A1", "A" & a)
FirstNo = Left(Testvariable, 1)
For i= 1 To a
If FirstNo(i,1) = "1" Then
Cells(i,2) = "abc" & FirstNo(i,1)
Else Cells(i,2) = "def" & FirstNo(i,1)
End if
Next
End Sub

A:

Trouble is you are trying to take the left of a Range object that happens to give you an array when assigned without the set keyword, when left wants a string.
This post here explains how to convert a range to a string, that you can then pass to left.
How can I convert a range to a string (VBA)?
Sub test()
    dim a as long
    a = UsedRange.Rows.Count
    dim Testvariable as string
    Testvariable = RangeToString(Range("A1", "A" & a))
    dim FirstNo as string
    FirstNo = Left(Testvariable, 1)
    dim i as long
    For i= 1 To a
        If FirstNo(i,1) = "1" Then
            Cells(i,2) = "abc" & FirstNo(i,1)
        Else 
            Cells(i,2) = "def" & FirstNo(i,1)
        End if
    Next
End Sub

Function RangeToString(ByVal myRange as Range) as String
    RangeToString = ""
    If Not myRange Is Nothing Then
        Dim myCell as Range
        For Each myCell in myRange
            RangeToString = RangeToString & "," & myCell.Value
        Next myCell
        'Remove extra comma
        RangeToString = Right(RangeToString, Len(RangeToString) - 1)
    End If
End Function

Also, be sure to always declare your variables correctly.
a = UsedRange.Rows.Count means create a variable called a of type variant and give it the value of UsedRange.Rows.Count
Testvariable = Range("A1", "A" & a) means create a variable called Testvariable of type variant and give it the .value of the range object (an array)
If these were declared properly
    dim a as long
    a = UsedRange.Rows.Count
    dim Testvariable as string
    Testvariable = Range("A1", "A" & a)

The assignment of Testvariable would have failed with a much more obvious error, informing you that you can't convert an array to a string.

