I REQUIRE SOME HELP WITH CODE

  • Thread starter tracks via OfficeKB.com
  • Start date
T

tracks via OfficeKB.com

The following is the code i need some help with

SUB co()
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Set rng1 = Worksheets("DATE").Range("B4")
Set rng2 = Worksheets("summ").Range("A6:.cells(rows.count,3).End
(xlUp)")
Set rng3 = Worksheets("summ").Range("A6:.CELLS(ROWS.COUNT,5).End
(xlUp)")
X = 0
Y = 0

If Month(rng1) > Month(rng2) Then
Range("rng3").Copy _
Worksheets("sheet3").Range("A6:E31").Offset(X, Y)

X = X + 7
Y = Y - 31

Else

End If


End Sub
when I try to run this in debugger to test it, I get the following error

Run-Time Error '1004':
Application-defined or Object-defined Error
please explain and help.

rick mason
 
J

Jim Thomlinson

What is that code supposed to do... it has both syntax and runtime issues...
 
T

thesquirrel

I notice in the following lines:
Set rng2 =
Worksheets("summ").Range("A6:.cells(rows.count,3).End (xlUp)")
Set rng3 =
Worksheets("summ").Range("A6:.CELLS(ROWS.COUNT,5).End (xlUp)")

you use ".CELLS" but I don't see a with statement to declare what these
are a part of.

Not sure if that is part of the problem, but could be part of it.

theSquirrel
 
T

tracks via OfficeKB.com

Jim said:
What is that code supposed to do... it has both syntax and runtime issues...
The following is the code i need some help with
[quoted text clipped - 30 lines]
rick mason
the code is used to compare the month on sheet "date" with the date in the
last entry in cloumn 'A'
if the month value is greater the the month value for the last entery, it
will copy range3 to a new sheet
ie "sheet3" the else statement would would have rng1 and rng2 copied to the
next blank row in sheet"summ'.
hope this explains what i want the code to do.
 
T

tracks via OfficeKB.com

I notice in the following lines:
Set rng2 =
Worksheets("summ").Range("A6:.cells(rows.count,3).End (xlUp)")
Set rng3 =
Worksheets("summ").Range("A6:.CELLS(ROWS.COUNT,5).End (xlUp)")

you use ".CELLS" but I don't see a with statement to declare what these
are a part of.

Not sure if that is part of the problem, but could be part of it.

theSquirrel
hi, Squirrel
i used the .Cells(row.count,3).End(xlUp) and .cells(rows.
count,5).End(xlUp) just to get to the last filled cell in column "A". i got
it from another posting i forgot that it required it to be identifed .

thanks Rick
The following is the code i need some help with
[quoted text clipped - 32 lines]
 
B

bz

tracks via OfficeKB.com said:
Set rng2 = Worksheets("summ").Range("A6:.cells(rows.count,3).End
(xlUp)")

I don't think this will work. If you get something that returns a string

Perhaps this would work, but I haven't tested it (if .cells... returns a
string in the right format)
.....
dim endrange as string
.....
endrange = .cells(rows.count,3).End(xlUp)
Set rng2 = Worksheets("summ").Range("A6:" & endrange)
.....

I think excel is trying to tell you that your 'string' "A6:.cells(....)"
isn't a valid argument for range.

--
bz

please pardon my infinite ignorance, the set-of-things-I-do-not-know is an
infinite set.

(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top