admin管理员组

文章数量:1192329

My vba was working perfectly fine and then all of a sudden is throwing variable mismatch errors and variable not defined errors for my next_row variable.

Sub data_input()
Dim ws_output As Sheet2

**next_row = Sheets(ws_output).Range("C" & Rows.Count).End(xlUp).Offset(1).Row**

Dim String1 As String
Dim String2 As String
Dim full_string As String
String1 = Range("Keywords").Value
String2 = Range("Other_Keywords").Value

Sheets(ws_output).Cells(next_row, 1).Value = String1 & ", " & String2
Sheets(ws_output).Cells(next_row, 2).Value = Range("Publication_Year").Value
Sheets(ws_output).Cells(next_row, 3).Value = Range("APA_Citation").Value
Sheets(ws_output).Cells(next_row, 4).Value = Range("Annotation").Value
Sheets(ws_output).Cells(next_row, 5).Value = Range("initials").Value

Range("Keywords").Value = ""
Range("Other_Keywords") = ""
Range("Publication_Year").Value = ""
Range("APA_Citation").Value = ""
Range("Annotation").Value = ""
Range("Initials").Value = ""

MsgBox "Your entry was submitted."

End Sub

I've tried defining the variable in different ways. Right now it is = to "empty" but I want it to return the row location for the rest of the code to work.

本文标签: excelVariable type mismatch in vba with finding next empty rowStack Overflow