marlbrarian
New Member
- Joined
- Sep 27, 2022
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hi there,
Old thread I know, I'm having a little bit of trouble getting something to work.
I'm also a bit of a novice, I'll admit.
I'm trying to Populate a table, this I've succeeded in.
Now however I need the information in a specific cell to be read and held against a portion of my table to ensure its not a duplicate.
Read from
Worksheet - Input
Cell C3
Compare to
Worksheet - Database
Tablename - FixDataBase
Column 1 (A), the column name is 'Suffix'
If a match is found I need an error message to be thrown up and the data for the table not to be put in.
(Also for the Cells not to be cleared, which they currently are at the end of the program.
I was attempting to modify the code above for my purpose but i couldn't get it working.
Any help would be greatly appreciated.
Old thread I know, I'm having a little bit of trouble getting something to work.
I'm also a bit of a novice, I'll admit.
I'm trying to Populate a table, this I've succeeded in.
Now however I need the information in a specific cell to be read and held against a portion of my table to ensure its not a duplicate.
Read from
Worksheet - Input
Cell C3
Compare to
Worksheet - Database
Tablename - FixDataBase
Column 1 (A), the column name is 'Suffix'
If a match is found I need an error message to be thrown up and the data for the table not to be put in.
(Also for the Cells not to be cleared, which they currently are at the end of the program.
I was attempting to modify the code above for my purpose but i couldn't get it working.
Any help would be greatly appreciated.
VBA Code:
Private Sub insertTAB_Click()
'change test to uppercase
Dim mycell As Range
Dim myrange As Range
'---------------------------
'Add Data into FixDataBase
Dim myRow As ListRow
Dim intRows As Integer
'---------------------------
'Prevent Duplicate Definitions here
'---------------------------
'change text to uppercase
Set myrange = ActiveWorkbook.Worksheets("Input").Range("C3:C4")
For Each mycell In myrange
mycell.Value = UCase(mycell.Value)
Next mycell
Set myrange = ActiveWorkbook.Worksheets("Input").Range("C8:C17")
For Each mycell In myrange
mycell.Value = UCase(mycell.Value)
Next mycell
'---------------------------
'Prevent Duplicate Code here
'---------------------------
'Add Data into FixDataBase
intRows = ActiveWorkbook.Worksheets("Database").ListObjects("FixDataBase").ListRows.Count
Set myRow = ActiveWorkbook.Worksheets("Database").ListObjects("FixDataBase").ListRows.Add(intRows)
myRow.Range(1) = Range("C3")
myRow.Range(2) = Range("C4")
myRow.Range(3) = Range("C5")
myRow.Range(4) = Range("C6")
myRow.Range(5) = Range("C8")
myRow.Range(6) = Range("C9")
myRow.Range(7) = Range("C13")
myRow.Range(8) = Range("C12")
myRow.Range(9) = Range("C17")
myRow.Range(10) = Range("C16")
'Clear Cell Contents on Completion of input
Range("C3:C17").Clear
End Sub