0
votes

I am using Excel Visual Basic for Applications (VBA)

I have a Macro that is selecting a set of cells, cutting them and pasting them into a defined cell in another sheet that the user selects. However, I need to have the macro look for empty rows (represented as a 0) in the user-chosen spreadsheet, as data may already be in the spot where it is getting pasted.

My Code:

Sub Button11_Click()
'
' Button11_Click Macro
'

'
    Range("A2:K2").Select
    Selection.Cut
    Sheets(Application.InputBox("Type desired Team")).Select
    Range("B4").Select
    Sheets("ImporterSheet").Select
End Sub

Basically,

Range(B4).Select

needs to be replaced with

Range(If ActiveCell <> 0 then ActiveCell.Offset(1,0). If ActiveCell = 0 then paste data here)
1

1 Answers

1
votes

Try this:

Range(Range("B:B").Find(0, [B1]).Address).Select

It selects the first cell with 0 in it in Column B.
Is this what you need?

BTW, try going through THIS which is definitely a good read to improve your coding.