Justinjc79
New Member
- Joined
- Jan 9, 2025
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello, I am making a form that has a list of employees pulled from a cell range. I am able to put them into 2 sperate categories in a user form that can move individually or all remaining between the 3 list boxes. The 4th panel is a preview of an email that is generated after the manual sorting process and the current source of my issue. The email preview is a Text box and I have the VBA coded to a button like :
txprv.value = "Hello!" & vbCrLf & vbCrLf & "We currently have " & Sheet1.Range("B2").Value & " in CORR with " & Sheet1.Range("B3").Value & _
" in total!" & vbCrLf & "We currently have " & Sheet1.Range("B1").Value & " in Processing!" & vbCrLf & "Please move to Accounting if you run out of work." _
& vbCrLf & vbCrLf & "CORR" & vbCrLf & Sheet1.Range F1:XX & vbCrLf & vbCrLf & Sheet1.Range F1:XX
The values in red is the data I am trying to add. I was able to script it so the results from the 2 sorted results list in the F column and G column but am struggling to have it take only the populated cells that vary. since the range currently runs from 1-30 based on number of names total and the amount could change variably. This is how it currently looks altogether including adding an array to determine how many cells in the column have data and have tried to use that value to add the names. If not I get the names added but it has a huge gap of unused cells.
Below is my current coding with "CORR" group filter attempt, and the myStr2 left for "Processing" displays the names from the 2nd list, but with all the spaces.
Private Sub CommandButton16_Click()
Dim myArray1 As Variant
Dim myArray2 As Variant
Dim myStr1 As String
Dim myStr2 As String
Dim x As Long
Dim y As Long
Dim a As Integer
Dim b As String
Dim c
Dim d As Long
Dim e As String
Dim f
Dim br1 As String
Dim br2 As String
br1 = Sheet1.Range("B7").Value
br2 = Sheet1.Range("B8").Value
a = Sheet1.Range("F30").End(xlUp).Row
b = Sheet1.Range("F" & a).Value
c = ListBox2.List
d = Sheet1.Range("G30").End(xlUp).Row
e = Sheet1.Range("G" & d).Value
f = ListBox3.List
'CORR NAMES IN COLUMN F
Sheet1.Range("F1").Resize(UBound(c) + 1, 1).Value = c
'PNDJ NAMES IN COLUMN G
Sheet1.Range("G1").Resize(UBound(f) + 1, 1).Value = f
'Populate range 1
myArray1 = Range("F1:F30").Value
For x = LBound(myArray1, 1) To UBound(myArray1, 1)
myStr1 = myStr1 & myArray1(x, 1) & vbCrLf
Next x
'Populate range 2
myArray2 = Range("G1:G30").Value
For y = LBound(myArray2, 1) To UBound(myArray2, 1)
myStr2 = myStr2 & myArray2(y, 1) & vbCrLf
Next y
txprv.value = "Hello!" & vbCrLf & vbCrLf & "We currently have " & Sheet1.Range("B2").Value & " in CORR with " & Sheet1.Range("B3").Value & _
" in total!" & vbCrLf & "We currently have " & Sheet1.Range("B1").Value & " in Processing!" & vbCrLf & "Please move to Accounting if you run out of work." _
& vbCrLf & vbCrLf & "CORR" & vbCrLf & (br1 & ":" & br2).value & "Processing" & vbCrLf & vbCrLf & myStr2
I have looked for similar issues here and tried working them in but they don't seem "compatible" when I run it and either gives an error or shows nothing. Any assistance is greatly appreciated, thank you!
txprv.value = "Hello!" & vbCrLf & vbCrLf & "We currently have " & Sheet1.Range("B2").Value & " in CORR with " & Sheet1.Range("B3").Value & _
" in total!" & vbCrLf & "We currently have " & Sheet1.Range("B1").Value & " in Processing!" & vbCrLf & "Please move to Accounting if you run out of work." _
& vbCrLf & vbCrLf & "CORR" & vbCrLf & Sheet1.Range F1:XX & vbCrLf & vbCrLf & Sheet1.Range F1:XX
The values in red is the data I am trying to add. I was able to script it so the results from the 2 sorted results list in the F column and G column but am struggling to have it take only the populated cells that vary. since the range currently runs from 1-30 based on number of names total and the amount could change variably. This is how it currently looks altogether including adding an array to determine how many cells in the column have data and have tried to use that value to add the names. If not I get the names added but it has a huge gap of unused cells.
Below is my current coding with "CORR" group filter attempt, and the myStr2 left for "Processing" displays the names from the 2nd list, but with all the spaces.
Private Sub CommandButton16_Click()
Dim myArray1 As Variant
Dim myArray2 As Variant
Dim myStr1 As String
Dim myStr2 As String
Dim x As Long
Dim y As Long
Dim a As Integer
Dim b As String
Dim c
Dim d As Long
Dim e As String
Dim f
Dim br1 As String
Dim br2 As String
br1 = Sheet1.Range("B7").Value
br2 = Sheet1.Range("B8").Value
a = Sheet1.Range("F30").End(xlUp).Row
b = Sheet1.Range("F" & a).Value
c = ListBox2.List
d = Sheet1.Range("G30").End(xlUp).Row
e = Sheet1.Range("G" & d).Value
f = ListBox3.List
'CORR NAMES IN COLUMN F
Sheet1.Range("F1").Resize(UBound(c) + 1, 1).Value = c
'PNDJ NAMES IN COLUMN G
Sheet1.Range("G1").Resize(UBound(f) + 1, 1).Value = f
'Populate range 1
myArray1 = Range("F1:F30").Value
For x = LBound(myArray1, 1) To UBound(myArray1, 1)
myStr1 = myStr1 & myArray1(x, 1) & vbCrLf
Next x
'Populate range 2
myArray2 = Range("G1:G30").Value
For y = LBound(myArray2, 1) To UBound(myArray2, 1)
myStr2 = myStr2 & myArray2(y, 1) & vbCrLf
Next y
txprv.value = "Hello!" & vbCrLf & vbCrLf & "We currently have " & Sheet1.Range("B2").Value & " in CORR with " & Sheet1.Range("B3").Value & _
" in total!" & vbCrLf & "We currently have " & Sheet1.Range("B1").Value & " in Processing!" & vbCrLf & "Please move to Accounting if you run out of work." _
& vbCrLf & vbCrLf & "CORR" & vbCrLf & (br1 & ":" & br2).value & "Processing" & vbCrLf & vbCrLf & myStr2
I have looked for similar issues here and tried working them in but they don't seem "compatible" when I run it and either gives an error or shows nothing. Any assistance is greatly appreciated, thank you!