Need msgbox text in a cell - msgbox

I want below message in a cell:
Dim Msg As String
Msg = "Files moved: " & MovedCount & "(" & NotMovedCount + MovedCount & ")"
If NotMovedCount > 0 Then
Msg = Msg & vbLf & "Files not moved:" & NotMovedCount & "(" _
& NotMovedCount + MovedCount & ")" & vbLf & vbLf _
& "The following files were not moved:" & vbLf _
& Join(dict.keys, vbLf)
End If
MsgBox Msg, IIf(NotMovedCount = 0, vbInformation, vbCritical)
Could you please help me.
I am moving some files from one folder to another. If the files are already available in the target folder, this code gives list in message box. However i need that information in excel cell for example sheet 1, cell AF5.

Related

How to populate listbox1 (without userform) with different colums from different sheets

My listbox is populated with 1 column of a specific sheet.
How can I get a second and third column in my listbox?
I mean... Column B from sheet1, column C from sheet2 and column B from sheet3, each with a second column from the sheets.
In this case I have a textbox where you can type your search.
This already works for me for just 1 specific column of 1 sheet:
Private Sub textbox1_change() 'zoekt via zoekterm boxpositie de mogelijke boxposities op
Dim i As Long
Dim x As Integer
Dim Sheet1 As Worksheet
TextBox1 = Format(StrConv(TextBox1, vbUpperCase))
Set Sheet1 = Worksheets("Cytolab")
a = TextBox1.TextLength
ListBox1.Clear
ListBox1.Height = 101
ListBox1.Top = 290
ListBox1.Width = 512
For i = 5 To Sheet1.Range("B238").End(xlUp).row
For x = 1 To Len(Sheet1.Cells(i, 2))
If UCase(Mid(Sheet1.Cells(i, 2), x, a)) = TextBox1 And TextBox1 <> "" Then
ListBox1.AddItem CStr(Sheet1.Cells(i, 2)) 'CStr() toegevoegd
ListBox1.List(ListBox1.ListCount - 1, 1) = "" & Sheet1.Cells(i, 3) & " · " & Sheet1.Cells(i, 7) & " · " & Sheet1.Cells(i, 5) & " · " & Sheet1.Cells(i, 4)
ListBox1.List(ListBox1.ListCount - 1, 2) = "" & Sheet1.Cells(i, 9)
End If
Next x
Next i
End Sub
Thank you.

How to transpose a 2D list with repeating objects

I have been trying to write some VBA in Excel to transpose a 2D list, based on searching for the first character "{".
Before:
After:
My code:
With Sheets("Results").Range(Cell1:="A1", Cell2:="A39")
Set a = .Find("{", After:=Range("A" & lRow))
Set b = a
c = a.Address
Do While Not .FindNext(b) Is Nothing And a.Address <> .FindNext(b).Address
c = c & "," & .FindNext(b).Address
rangeToMoveCell1 = a.Address
rangeToMoveCell2 = .FindNext(b).Address
MsgBox ("rangeToMoveCell1: " & rangeToMoveCell1 & vbNewLine & "rangeToMoveCell2: " & rangeToMoveCell2)
Sheets("Results").Range(Cell1:=rangeToMoveCell1, Cell2:=rangeToMoveCell2).Copy
Sheets("Results").Range(Cell1:=rangeToMoveCell1, Cell2:=rangeToMoveCell2).Offset(-3, 1).PasteSpecial Transpose:=True
Sheets("Results").Range(Cell1:=rangeToMoveCell1, Cell2:=rangeToMoveCell2).Clear
Set b = .FindNext(b)
Loop
End With
I've come up with this and it works, except it does not process the last find:
With Sheets("Results").Range(Cell1:="A1", Cell2:="A" & lRow)
Set a = .Find("{", After:=Range("B" & lRow))
Set b = a
c = a.Offset(3).Address
Do While Not .FindNext(b) Is Nothing And a.Address <> .FindNext(b).Address
Set nextFind = .FindNext(b)
Set d = nextFind
'MsgBox ("d: " & d)
e = nextFind.Offset(-1, 1).Address
Sheets("Results").Range(Cell1:=c, Cell2:=e).Copy
Sheets("Results").Range(Cell1:=c, Cell2:=e).Offset(-3, 2).PasteSpecial Transpose:=True
Sheets("Results").Range(Cell1:=c, Cell2:=e).EntireRow.Delete
Sheets("Results").Range(c).EntireRow.Insert
Sheets("Results").Range(c).EntireRow.Insert
c = nextFind.Offset(3).Address
Set b = .FindNext(b)
Loop
End With

Formula references data that are not shown

I need some help with my Google Sheets... I don't understand why but my data are capricious...
I use a simple ={'Mysheet'!A1:D} and I get only the first cell.
Please find a link to a copy of my sheet. The problem is in 'Up&Down OR'
https://docs.google.com/spreadsheets/d/1HJ_bqQtsjWe9RxaDzLUypY-D9dyuqWNpw2pG0XHVYjI/edit?usp=sharing
most likely there is some residue from the script you are usiing but you can always reference original:
=QUERY(Encodage!A1:AAA ;"select C, " & params!K1 & ", " & params!L1 & ", " & params!M1 & " where A = FALSE AND B = '1OR' ORDER BY " & params!K1 & " + " & params!L1 & " + " & params!M1 & " LIMIT 10 LABEL " & params!K1 & " '" & INDIRECT("Encodage!"& params!K1 & "1") & "', " & params!L1 & " '" & INDIRECT("Encodage!"& params!L1 & "1") & "', " & params!M1 & " '" & INDIRECT("Encodage!"& params!M1 & "1") & "'" ;1)

how to combine 2 textjoins with "AND" and "OR" statements in google docs query?

I have a query:
=query(test_data_set!A2:C;"SELECT A, B, C" & if(countblank(dash!C1:C6)=6;"";" WHERE " & textjoin(" OR "; true; dash!C1:C4)) & "ORDER BY B";0)
in C1:C4 there is a text
in C5:C6 there is 2 dates
so i need to add in query textjoin(" AND "; true; dash!C5:C6)
How can i do it?
the way i do it doesn't work:
=query(test_data_set!A2:C;"SELECT A, B, C" & if(countblank(dash!C1:C6)=6;"";" WHERE " & textjoin(" OR "; true; dash!C1:C4) & textjoin(" AND "; true; dash!C5:C6)) & "ORDER BY B";0)
please help
that works
=IFERROR(query(test_data_set!A2:C;"SELECT A, B, C WHERE A IS NOT NULL" & if(countblank('Dazrin Copy of Dash'!C1:C6)=ROWS(C1:C6);"";" AND " &IF(COUNTBLANK(C1:C4)<>ROWS(C1:C4);"("& textjoin(" OR "; true; 'Dazrin Copy of Dash'!C1:C4)&")";) &IF(AND(COUNTBLANK(C1:C4)<>ROWS(C1:C4);COUNTBLANK(C5:C6)<>ROWS(C5:C6));" AND ";)& "("&textjoin(" AND "; true; 'Dazrin Copy of Dash'!C5:C6) & ")") & " ORDER BY B ASC";0);"No items found")

How to resize side by side controls in MS ACCESS 2007

I have a form in which there are various fields, for ex. Two textboxes are side by side.
These 2 textbox have anchor property left,top and other right,top.
Now when I resize the form the controls are aligned to left and the other textbox to right.
But when as screen is maximized it leaves a blank space in between these two textboxes.
So then I made the anchor property of both textbox to both,both the controls overlapped.
PS: working on MS ACCESS 2007.
anchoring property above is Horizontal, Vertical
EDIT : In Normal window
_______________________Min Max Close_
| First_Name TEXTBOX Last_Name TEXTBOX |
|_______________________________|
When Maximized to whole screen it gives me
_____________________________________Min Max Close_
| First_Name TEXTBOX ............................. Last_Name TEXTBOX |
|______________________________________________|
And I need this way as below
_____________________________________Min Max Close_
| F i r s t_N a m e T E X T B O X ........ L a s t_N a m e T E X T B O X |
|______________________________________________|
I am trying to explain by doing all this as I am not allowed to upload a image, Sorry for that....
Paste the following code into your form, change the field names, and see what happens. The two fields will 'grow' as you increase the form width, yet maintain their Anchor. Note: I updated on 3/3 to handle the field labels.
Option Compare Database
Option Explicit
Dim fviInsideWidth As Integer
Dim fviSaveInsideWidth As Integer
Dim fviFormWidth As Integer
Dim fviFldWidth As Integer
Dim fviFieldGap As Integer
Dim fviRemainder As Integer
Dim fviLblWidth As Integer
Dim fviRLblToTxt As Integer
Dim fvstrLLabel As String
Dim fvstrRLabel As String
Private Sub Form_Open(Cancel As Integer)
fviSaveInsideWidth = Me.InsideWidth
fviInsideWidth = Me.InsideWidth
fviFormWidth = Me.Width
fviFldWidth = Me.fldLeft.Width + Me.fldRight.Width
fviRemainder = fviInsideWidth - fviFldWidth
fviFieldGap = Me.fldRight.Left - (Me.fldLeft.Left + Me.fldLeft.Width)
fvstrLLabel = Me.fldLeft.Controls.Item(0).Name
fvstrRLabel = Me.fldRight.Controls.Item(0).Name
fviLblWidth = Me.Controls(fvstrRLabel).Width
fviRLblToTxt = Me.fldRight.Left - Me.Controls(fvstrRLabel).Left
'Debug.Print "Open - InsideWidth = " & fviInsideWidth & " Fields: " & fviFldWidth & " Remainder: " & fviRemainder
'Debug.Print "Open - Form Width = " & Me.Width & vbTab & "Diff = " & fviInsideWidth - fviFormWidth
End Sub
Private Sub Form_Close()
Me.fldLeft.Width = fviFldWidth
Me.fldRight.Width = fviFldWidth
Me.InsideWidth = fviSaveInsideWidth
End Sub
Private Sub Form_Resize()
Dim ifldWidth As Integer
Dim ifrmWidth As Integer
fviInsideWidth = Me.InsideWidth
ifrmWidth = fviInsideWidth - 1110
Me.Width = ifrmWidth
ifldWidth = Int((fviInsideWidth - fviRemainder) / 2)
Me.fldLeft.Width = ifldWidth
Me.fldRight.Left = Me.fldLeft.Left + Me.fldLeft.Width + fviFieldGap
Me.Controls(fvstrRLabel).Left = Me.fldRight.Left - fviRLblToTxt
Me.fldRight.Width = ifldWidth
'Debug.Print "Resize - InsideWidth = " & fviInsideWidth & vbTab & "Form Width = " & Me.Width & " Flds: " & ifldWidth & " Right=" & Me.fldLeft.Left + Me.fldLeft.Width + fviFieldGap
'Debug.Print "Resize Form: " & Me.Width & " Flds: " & ifldWidth
Me.Repaint
End Sub

Resources