Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 - Run-time Error 1004

Status
Not open for further replies.

okeyuzosike

Programmer
Jun 15, 2007
15
US
Hi everyone,
I have a spreadsheet with information in some of the colums: ("A:Y").
I want to move(relocate the content of column "A" to any column that does not have data(values).
In other words, I want to cut the content of Column "A", loop through the rest of the columns to find a column that has not no data, then past the content of Columns A in tha location.
I am using the code below and I am getting Runtime error 1004 on the second line:

For i = 1 To 256
If Application.CountA(Range(Cells(1, i), Cells(65536, i))) = 0 Then
Columns(2).Cut Destination:=Columns(i)
Exit For
End If
Next i

how can I fix this?
Thanks.
Okey.
 
Why are you talking about VB6 in the title ?
If you automate excel then you have to use full qualified excel objects:
If yourXLapp.CountA(yourXLapp.Range(yourXLappCells(1, i), yourXLapp.Cells(65536, i))) = 0 Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry for the typo:
If yourXLapp.CountA(yourXLapp.Range(yourXLapp.Cells(1, i), yourXLapp.Cells(65536, i))) = 0 Then
 
Thanks PHV. I am trying to specify VB6 so that people know what program I am coding in.
Thanks for your input I very much appreciate your swift response.
O.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top