How can I change this code...

lucky12341

Board Regular
Joined
Nov 4, 2005
Messages
121
I am using this code to enter basic data into the next available empty cell in A1 from an input form. Can I change the code to find an entry that is in the A column and then enter data in the neighboring B,C etc columns, i.e. information is maybe in cell A76 and the information would be entered in B76 and C76, just as an example. Thanks

Private Sub Accept_Click()

ActiveWorkbook.Sheets("Inventory").Activate

Range("A1").Select

Do

If IsEmpty(ActiveCell) = FalseThen

ActiveCell.Offset(1, 0).Select

End If

Loop Until IsEmpty(ActiveCell) = True

ActiveCell.Value = PObox.Value

ActiveCell.Offset(0, 1) = PCMKbox.Value

ActiveCell.Offset(0, 2) = Partbox.Value

ActiveCell.Offset(0, 3) = Descriptionbox.Value

ActiveCell.Offset(0, 4) = Materialbox.Value

ActiveCell.Offset(0, 5) = Drawingbox.Value

ActiveCell.Offset(0, 6) = Qtybox.Value

ActiveCell.Offset(0, 7) = HICbox.Value


End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi
try (not tested)
Code:
Sub test()
Dim r As Range
Set r = Sheets("Inventory").Columns(1).Find("*", Cells(1, 1), , , , xlPrevious)
If r.Row = Rows.Count Then MsgBox "No place to output!": Exit Sub
r.Value = PObox.Value
With r.Offset(1)
    .Offset(0, 1) = PCMKbox.Value
    .Offset(0, 2) = Partbox.Value
    .Offset(0, 3) = Descriptionbox.Value
    .Offset(0, 4) = Materialbox.Value
    .Offset(0, 5) = Drawingbox.Value
    .Offset(0, 6) = Qtybox.Value
    .Offset(0, 7) = HICbox.Value
End With
End Sub
 
Upvote 0
Use Columns(1).Find(POBox.value) to see if the value already exists in the data set.
lucky12341 said:
I am using this code to enter basic data into the next available empty cell in A1 from an input form. Can I change the code to find an entry that is in the A column and then enter data in the neighboring B,C etc columns, i.e. information is maybe in cell A76 and the information would be entered in B76 and C76, just as an example. Thanks
{snip}
 
Upvote 0
I am not sure how to write the code to put the columns thing in...can you explain or give me an example to fit it into the code...thanks
 
Upvote 0

Forum statistics

Threads
1,203,521
Messages
6,055,883
Members
444,830
Latest member
Excelsmallbusinessmom

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