Hello,
I couldnt find any similar question nad i also looked the problem up. I am new in the game
I have two sheets: One as a mask, so you can write the information in the cells ("mask") and one sheet as a table where the makro will copy the data in the mask an paste them in the table ("register table").
The Cell C2 in sheet "mask" is a cell with a dropdown list. I want my program to check if the cell is empty (nothing is selected in the dropdown lsit), and if so, to give an error message. Nothing worked so far.
Sub newEntry()
Application.ScreenUpdating = False
Sheets("register table").Select
Dim findword$, c, fA
Probenart$ = Sheets("mask").Range("C2")
If Sheets("mask").Range("C2") Is Nothing Then
MsgBox " C2 its empty!"
Exit Sub
With ActiveSheet.Cells
With .Columns(1)
Set c = .Find(findword$, LookIn:=xlValues)
'if c not null
If Not c Is Nothing Then
fA = c.Address
Do
Rows(c.Row + 1).Insert Shift:=xlShiftDown, CopyOrigin:=xlFormatFromRightOrBelow
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> fA
Sheets("Eingabemaske").Select
Range("C3:C28").Select
Selection.Copy
Sheets("register table").Select
Rows(c.Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Selection.Interior.ColorIndex = 0
Sheets("mask").Select
Range("C2:C28").Select
Selection.ClearContents
Sheets("register table").Select
End If
End With
End With
End If
Application.ScreenUpdating = True
End Sub
Thanks!
- r1d1
I couldnt find any similar question nad i also looked the problem up. I am new in the game
I have two sheets: One as a mask, so you can write the information in the cells ("mask") and one sheet as a table where the makro will copy the data in the mask an paste them in the table ("register table").
The Cell C2 in sheet "mask" is a cell with a dropdown list. I want my program to check if the cell is empty (nothing is selected in the dropdown lsit), and if so, to give an error message. Nothing worked so far.
Sub newEntry()
Application.ScreenUpdating = False
Sheets("register table").Select
Dim findword$, c, fA
Probenart$ = Sheets("mask").Range("C2")
If Sheets("mask").Range("C2") Is Nothing Then
MsgBox " C2 its empty!"
Exit Sub
With ActiveSheet.Cells
With .Columns(1)
Set c = .Find(findword$, LookIn:=xlValues)
'if c not null
If Not c Is Nothing Then
fA = c.Address
Do
Rows(c.Row + 1).Insert Shift:=xlShiftDown, CopyOrigin:=xlFormatFromRightOrBelow
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> fA
Sheets("Eingabemaske").Select
Range("C3:C28").Select
Selection.Copy
Sheets("register table").Select
Rows(c.Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Selection.Interior.ColorIndex = 0
Sheets("mask").Select
Range("C2:C28").Select
Selection.ClearContents
Sheets("register table").Select
End If
End With
End With
End If
Application.ScreenUpdating = True
End Sub
Thanks!
- r1d1