activecell.entirerow.value2 problem

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
Hi

I am having problems with a value check.
Basically:
I have pulled data from a csv file into my workbook. During this cut'n'paste exersize I have found that some values are n/a.

When this happens I want the value of the cell 4 to the right (on the same row) to replace the n/a.

for example:
Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAK
825/10/20091071MSCHI050MS Chillies Mixed 50g8006612n/an/aOrangeULGenovese3090000 3090 000040122198232685961
inDATA


Here Q8 and S8 have n/a values I want Q8 to be 66 and S8 to be 12

My code for doing this is:
Code:
For Each Colour In TestForColour.Cells
    If Colour.Value <> "" Then
        Intersect(ActiveCell.EntireRow, Columns("A:AJ")).Copy
        wbThis.Activate
        Sheets("PROPHETDATA").Select
        Selection.PasteSpecial Paste:=xlPasteValues
        If (ActiveCell.EntireRow.Value2(1, 17)) = "n/a" Then ActiveCell.EntireRow.Value2(1, 17) = ActiveCell.EntireRow.Value2(1, 13)
        If (ActiveCell.EntireRow.Value2(1, 19)) = "n/a" Then ActiveCell.EntireRow.Value2(1, 19) = ActiveCell.EntireRow.Value2(1, 15)
        Range("A" & A).Select
        ActiveCell = DateValue(ArrivalDate)
        A = A + 1
        Range("B" & A).Select
        ActiveWindow.ActivatePrevious
        
    End If
b = b + 1
Range("U" & b).Select
Next Colour
the module compiles ok and runs though it ok
checking the values they are correct but the cell does not update

any ideas

Martin
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Is Excel currently set for Automatic Calculation versus Manual?
Its currently set to manual

The process is kicked off bey a button

Code:
ActiveSheet.Unprotect
Application.EnableEvents = False
Application.ScreenUpdating = False
With Application
     .Calculation = xlCalculationManual
End With
.
.
.
.
Application.EnableEvents = True
Application.ScreenUpdating = True
ActiveSheet.Protect
With Application
    .Calculation = xlAutomatic
End With
 
Upvote 0
update
changing the code to:
Code:
        With Application
            .Calculation = xlCalculationAutomatic
        End With
        Application.EnableEvents = True
        Application.ScreenUpdating = True

        If (ActiveCell.EntireRow.Value2(1, 17)) = "n/a" Then ActiveCell.EntireRow.Value2(1, 17) = ActiveCell.EntireRow.Value2(1, 13)
        'Me.Calculate
        If (ActiveCell.EntireRow.Value2(1, 19)) = "n/a" Then ActiveCell.EntireRow.Value2(1, 19) = ActiveCell.EntireRow.Value2(1, 15)
        'Me.Calculate
           'turn off auto calc
        With Application
            .Calculation = xlCalculationManual
        End With
        Application.EnableEvents = False
        Application.ScreenUpdating = False
has not made any difference. As you can see I also tried the Me.Calculate command but excel did not like it.

Martin
 
Upvote 0
Try:

Code:
Sub Test()
If (ActiveCell.EntireRow.Value2(1, 17)) = "n/a" Then Cells(ActiveCell.Row, 17) = Cells(ActiveCell.Row, 13)
        If (ActiveCell.EntireRow.Value2(1, 19)) = "n/a" Then Cells(ActiveCell.Row, 19) = Cells(ActiveCell.Row, 15)
        Range("A" & A).Select
End Sub
 
Upvote 0
Thanks Jim

That did it. can you explain the difference between your and my code.
I see you wrapped a Cells around mine bt why did it need it???

Martin
 
Upvote 0
Once the condition was met ("n/a" = True) you were saying
Copy a designated cell of the EntireRow to a Designated cell of the EntireRow
Excel CHOKES on such instructions.
You wanted when the condition was met ("n/a" = True) to
Copy a single designated cell of the Activecell.row to another single cell of the same Activecell.row. Use of the Entirerow took you UP to too high of a level (multiple cells)
where you are dealing with single cells at this point.
Does this make sense?
Hope So !!!

Jim
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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