what's wrong with this?

chammy88

Board Regular
Joined
Jun 24, 2011
Messages
56
I have done the following:

Sub Group()
Sheets("calcs").Select
Range("F2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
Dim LR As Long, i As Long
With Sheets("AmplaData")
LR = .Range("AO" & Rows.Count).End(xlUp).row
For i = 2 To LR
With .Range("AO" & i)
If .Value = 1 Then .Offset(, -24).Resize(, 1).Copy Destination:=Sheets("calcs").Range("F" & Rows.Count).End(xlUp).Offset(1)
If .Value = 1 Then .Offset(, -22).Resize(, 1).Copy Destination:=Sheets("calcs").Range("G" & Rows.Count).End(xlUp).Offset(1)
If .Value = 1 Then .Offset(, -17).Resize(, 1).Copy Destination:=Sheets("calcs").Range("H" & Rows.Count).End(xlUp).Offset(1)
If .Value = 1 Then .Offset(, -14).Resize(, 1).Copy Destination:=Sheets("calcs").Range("I" & Rows.Count).End(xlUp).Offset(1)
If .Value = 1 Then .Offset(, -13).Resize(, 1).Copy Destination:=Sheets("calcs").Range("J" & Rows.Count).End(xlUp).Offset(1)
If .Value = 1 Then .Offset(, -12).Resize(, 3).Copy Destination:=Sheets("calcs").Range("K" & Rows.Count).End(xlUp).Offset(1)
End With
Next i
End With
Worksheets("Calcs").Range("F:F").NumberFormat = "dd/mm/yy hh:mm:ss"
Worksheets("Calcs").Range("G:G").NumberFormat = "dd/mm/yy hh:mm:ss"
If Worksheets("Calcs").Range("J:J").String = "Pilbara Iron.Brockman 2.Plant" Then Worksheets("Calcs").Range("J:J").String = "Pilbara Iron.Brockman 2.Primary Crushing"

The code works until it gets to the If statement in bold where I get a runtime error '438' : Object doesn't support this property or method.

Does anyone have any ideas/suggestions?


Thanks in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
There is no such property as String -- change it to Value. But you can't compare an array of values to a single string.

What are you trying to do?
 
Upvote 0
yeah, I realised that I had it as .value first and it didn't work so I tried .string but forgot to change it back before copying it into the thread.

I just want to say if anything in column J says "Pilbara Iron.Brockman 2.Plant" then chance it to "Pilbara Iron.Brockman 2. Primary Crushing"

Thanks
 
Upvote 0
Maybe

Code:
    Worksheets("Calcs").Range("J:J").Replace "Pilbara Iron.Brockman 2.Plant", _
                                             "Pilbara Iron.Brockman 2.Primary Crushing"
 
Upvote 0
You're welcome, glad it worked for you.
 
Upvote 0

Forum statistics

Threads
1,224,519
Messages
6,179,263
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top