Worksheet “Sheet1” contains an excel table that has 6 columns, 40 rows with a header row beginning in worksheet row #7. The first 6 rows of the worksheet are blank.
When called from a macro button on the worksheet, the above code writes txtSTR to the cells in column 2 and 3 of row 9 in the table (corresponding to row 16 of the worksheet). This is what I would expect and want to happen.
However, when the same identical code is called from within a Userform, the data is written to the cells in column 2 and 3 of row 16 in the table (corresponding to row 23 of the worksheet) i.e. the right columns but wrong row. I’ve been trying to figure this out for some time now, without any joy. Maybe I’m not seeing something very obvious, but I would appreciate any insight. I understand that I could code around this by adjusting the rownum variable, but I’m really baffled as to why the code operated differently.
Bookmarks