Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure but the way you are calling your range seems strange to me. Try a different way of defining your count range. </p> <p>Change this:</p> <pre><code>nextrow = WorksheetFunction.CountA(Sheets("DB Cust").Range("C:C")) + 2 </code></pre> <p>To this:</p> <pre><code>Dim myWB as Workbook, DBcust as Worksheet Set myWB = Excel.ActiveWorkbook Set DBcust = myWB.Worksheets("DB Cust") nextrow = Excel.WorksheetFunction.CountA(DBcust.Range(DBcust.Cells(1,3),DBcust.Cells(DBcust.UsedRange.Rows.Count,3)) + 2 </code></pre> <p>I assigned the book and sheet to a variable for more reliability, but you can explicitly state them again if you wanted to. This code assumes the workbook is the currently active workbook, if not you will have to set the variable using the workbook name. </p> <p>Also, it doesn't look like you need the "rfound" portion of the offset function within the "With" block . . . that is what the "With" is there for. It's just a little thing but meaningless code like that will only cause you extra headache so my advice would be to take it out.</p> <p>I haven't loaded this into the VBA IDE so please double check for spelling errors. Thanks!</p> <p>UPDATE:</p> <p>After reading your comment, I took a closer look at your code and what it is you're trying to do. It looks like you are trying to place the value of textbox1 (whatever that may be...it would help if you explained this part a little) into a cell offset from the location of a search result defined by the user in combobox1. The nextrow variable is inside the row offset parameter, but the location is already where you want it to be. Try changing this:</p> <pre><code>With rfound rfound.Offset(nextrow, 1).Value = TextBox1.Value rfound.Offset(nextrow, 2).Value = TextBox1.Value rfound.Offset(nextrow, 3).Value = TextBox1.Value rfound.Offset(nextrow, 4).Value = TextBox1.Value rfound.Offset(nextrow, 5).Value = TextBox1.Value rfound.Offset(nextrow, 6).Value = TextBox1.Value rfound.Offset(nextrow, 7).Value = TextBox1.Value rfound.Offset(nextrow, 8).Value = TextBox1.Value MsgBox ("Data entry success") End With </code></pre> <p>To this:</p> <pre><code>With rfound .Offset(0, 1).Value = TextBox1.Value .Offset(0, 2).Value = TextBox1.Value .Offset(0, 3).Value = TextBox1.Value .Offset(0, 4).Value = TextBox1.Value .Offset(0, 5).Value = TextBox1.Value .Offset(0, 6).Value = TextBox1.Value .Offset(0, 7).Value = TextBox1.Value .Offset(0, 8).Value = TextBox1.Value MsgBox ("Data entry success") End With </code></pre> <p>You may notice I also removed the redundant "rfound" as per my previous advice. See if this works and if so you may want to remove the newrow variable all together.</p> <p>Good luck and let us know how it goes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload