Add Data validation List VBA to cell

cagni

New Member
Joined
Aug 1, 2022
Messages
24
Office Version
  1. 365
Platform
  1. Windows
Hi All

I have this list where I create new claims. Every time I enter a new claim it makes a new row and the last one moves down the list, and the lastest is on top. Now I would like to have some "status" drop down list on each of the claims. These have to when I create the new claim, so it has to be with in my current "rookie code:)".

It only needs to be 2-3 choices, probably only 2 "In progress" and "Completed". The list needs to be on G8, H8 and I8.

The last part is just where it creates a folder with claim number and year.

I know my code is really not that good, but I´m really a rookie and I´m learning slowly.

Hope someone can help, or let me know if it doesn´t make sense.

VBA Code:
Private Sub addProject_Click()

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Ark1")

Sheets("Ark1").Range("A8").Select
ActiveCell.EntireRow.Insert shift:=xlDown

Sheets("Ark1").Range("B8:J8").Select
Selection.Borders.Weight = xlThin

Sheets("Ark1").Range("B8:J8").Select
Selection.Font.Size = 11

Sheets("Ark1").Range("B8:J8").Select
Selection.Font.Bold = False

Sheets("Ark1").Range("D8").Select
ActiveCell.Value = Date

With ws
Sheets("Ark1").Range("B8").Select
ActiveCell.Value = Me.TextBox1.Value

Sheets("Ark1").Range("C8").Select
ActiveCell.Value = Me.TextBox2.Value

Sheets("Ark1").Range("E8").Select
ActiveCell.Value = Me.TextBox3.Value

Sheets("Ark1").Range("F8").Select
ActiveCell.Value = Me.TextBox4.Value

End With

'clear the data
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox1.SetFocus

    Dim wb As Workbook
    Dim p As String, NwPath As String
    Dim c1 As String, c2 As String
    Dim folder As String

    Set wb = ThisWorkbook
    p = wb.Path & "\"
    Set ws = wb.Sheets("Ark1")
   
    With ws
        c1 = .Range("B3").Value
        c2 = .Range("B8").Value
    End With
   
    NwPath = p & c2 & "_" & c1
    'check if folder exists, if not then create folder
    folder = Dir(NwPath, vbDirectory)
    If folder = vbNullString Then
        VBA.FileSystem.MkDir (NwPath)
    End If

  Unload Me

End Sub

2022-11-22 11_40_45-Window.png

2022-11-22 11_41_13-Window.png
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You could change the first section to:

VBA Code:
Private Sub addProject_Click()

   Dim iRow As Long
   Dim ws As Worksheet
   Set ws = Worksheets("Ark1")

   With ws
      .Range("A8").EntireRow.Insert shift:=xlDown

      With .Range("B8:J8")
         .Borders.Weight = xlThin
         With .Font
            .Size = 11
            .Bold = False
         End With
      End With

      .Range("D8").Value = Date
      .Range("B8").Value = Me.TextBox1.Value
      .Range("C8").Value = Me.TextBox2.Value
      .Range("E8").Value = Me.TextBox3.Value
      .Range("F8").Value = Me.TextBox4.Value

      With .Range("G8:I8").Validation
         .Delete
         .Add Type:=xlValidateList, Formula1:="In progress,Completed"
         .InCellDropdown = True
      End With

   End With
 
Upvote 0
Solution
A reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
A reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
Hi RoryA

Sorry didn´t know this. I will try to delete the post on the second forum.

Thanks for the help with the issue.
 
Upvote 0
You don't need to delete it, you just needed to provide links (both here and over there) to the crossposts. If you read the rules and the link, you will understand why.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top