Trying to fill values to cells

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
631
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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Sorry, this is now sorted. Had the wrong column in the code.
 
Last edited:
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
Solution

Forum statistics

Threads
1,214,653
Messages
6,120,757
Members
448,991
Latest member
Hanakoro

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