Trying to fill values to cells

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
612
Office Version
  1. 2019
Platform
  1. Windows
I am trying to say if cell A10 is under 3200 then fill in 6 to selected cells if not then 8
For some reason, nothing happens?
If it helps I could send the workbook?

VBA Code:
Private Sub HingeQty()

Dim ws As Worksheet
Dim iRow As Integer


Set ws = ThisWorkbook.Worksheets("Job Card Master")

With ws

If .Range("A10") <= 3200 Then


    iRow = .Range("E13:F" & .UsedRange.Rows.Count).Find("SIDEBOARD", LookIn:=xlValues, lookat:=xlWhole).Row
    iRow = iRow + 4
    .Cells(iRow, 8) = 6
    .Cells(iRow + 1, 8) = 6
    Else
    iRow = .Range("E13:F" & .UsedRange.Rows.Count).Find("SIDEBOARD", LookIn:=xlValues, lookat:=xlWhole).Row
    iRow = iRow + 4
    .Cells(iRow, 8) = 8
    .Cells(iRow + 1, 8) = 8
   
End If
End With

End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
612
Office Version
  1. 2019
Platform
  1. Windows
Sorry, this is now sorted. Had the wrong column in the code.
 
Last edited:

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
51,223
Office Version
  1. 365
Platform
  1. Windows
Glad to hear you got the solution.

Do you mind posting your corrected code? Then it is perfectly fine to mark your post as the solution to help future readers.
The tick marks are to mark the actual solution, not just the fact that you have found a solution.
 

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
612
Office Version
  1. 2019
Platform
  1. Windows
VBA Code:
Private Sub HingeQty()


Dim iRow As Integer
Dim RangeRow As Range
Dim ws As Worksheet

Set ws = ThisWorkbook.Worksheets("Job Card Master")

If ws.Range("A10") <= 3200 Then


    Set RangeRow = ws.Range("C13:C" & ws.UsedRange.Rows.Count).Find("SIDEBOARD", LookIn:=xlValues, lookat:=xlWhole)
    If Not RangeRow Is Nothing Then
    iRow = RangeRow.Row + 3
    ws.Cells(iRow, 8) = 6
    ws.Cells(iRow + 1, 8) = 6
    Else
    Set RangeRow = ws.Range("C13:C" & ws.UsedRange.Rows.Count).Find("SIDEBOARD", LookIn:=xlValues, lookat:=xlWhole)
    If Not RangeRow Is Nothing Then
    iRow = RangeRow.Row + 3
    ws.Cells(iRow, 8) = 8
    ws.Cells(iRow + 1, 8) = 8
    End If
    End If
    
    Set RangeRow = ws.Range("C13:C" & ws.UsedRange.Rows.Count).Find("SIDEBOARD-DROPSIDE", LookIn:=xlValues, lookat:=xlWhole)
    If Not RangeRow Is Nothing Then
    iRow = RangeRow.Row + 3
    ws.Cells(iRow, 8) = 6
    Else
    Set RangeRow = ws.Range("C13:C" & ws.UsedRange.Rows.Count).Find("SIDEBOARD-DROPSIDE", LookIn:=xlValues, lookat:=xlWhole)
    If Not RangeRow Is Nothing Then
    iRow = RangeRow.Row + 3
    ws.Cells(iRow, 8) = 8
    End If
    End If
    End If
 
Solution

Forum statistics

Threads
1,144,630
Messages
5,725,394
Members
422,623
Latest member
Dave52

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
Top