Copy and paste cells to a new sheet - Cells are defined by condi

alicegodet - Nov 26, 2017 at 07:34 PM

I have got a sub with a condition. If the condition is True, I want cells from one column to be copied to a column in another sheet

First Sub (beginning)

Sub Concattest()
ActiveWorkbook.Worksheets("Test 4").Select
'Test = Read data

Dim LastColumn As Long
Dim LastRow As Long

'Find LastRow and LastColumn
LastRow = ActiveWorkbook.Worksheets("Test 4").UsedRange.Rows.Count
LastColumn = ActiveWorkbook.Worksheets("Test 4").UsedRange.Columns.Count

MsgBox LastRow
MsgBox LastColumn

'i represent the row counter
'j represents the column counter
Dim i As Integer, j As Integer

'k is the final number of columns which equals the number of main questions
Dim k As Integer

'Test assesses if two columns are related to the same question or not
Dim Test As Boolean

i = 3
j = 4
k = 4

'Case: there is no underscore in column j
Test = Worksheets("Test 4").Cells(1, j).Value Like "*_*"
If Test = False Then Call NoUnderscore

Second Sub

Sub NoUnderscore()

For i = 1 To LastRow

Worksheets("Test 4").Cells(i, j).Copy Destination:=Worksheets("Sheet5").Cells(i, k)

Next i

End Sub

There is not mistake but it does not copy cells at all... nothing happens basically

Any idea on what I should do?

See more