I'am very new to the VBA and macros and wanted to make my life a bit easier. I created a simple macro that formats my data to desired shape but then I have to copy the contents by hand into main file. Tried to ask chatGPT but there are issues and we cant work this out.
My simple macro is:
Sub FakturyWklejanieRaportów()
' FakturyWklejanieRaportów Macro
Rows("1:4").Select
Selection.Delete Shift:=xlUp
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("A:A,C:C,F:F,G:G,H:H").Select
Range("H1").Activate
Selection.Delete Shift:=xlToLeft
Range("C3").Select
Columns("B:B").Select
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1)), _
TrailingMinusNumbers:=True
Range("B:B,D:D,E:E,F:F,G:G,H:H,I:I,J:J,K:K,L:L,M:M").Select
Range("M1").Activate
Selection.Delete Shift:=xlToLeft
Selection.ColumnWidth = 16.73
Columns("A:B").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B$9999").AutoFilter Field:=2, Criteria1:=Array("1", _
"2", "3", "4", "finished", "selected", "started", "="), Operator:=xlFilterValues
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Columns("B:B").Select
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(0, 1), TrailingMinusNumbers:=True
Columns("A:A").Select
Selection.Replace What:=".", Replacement:="/", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Columns("B:B").Select
ActiveSheet.Range("$A$1:$B$9999").RemoveDuplicates Columns:=2, Header:=xlNo
End Sub
I guess line like that opens multiple workbooks but after that my abilities run out..
sourceFilePath = Application.GetOpenFilename("Excel Files (*.xls; *.xlsx), *.xls;*.xlsx", , "Select Source Files", , True)
If TypeName(sourceFilePath) = "Boolean" Then
MsgBox "No files selected. Macro terminated.", vbExclamation
Exit Sub
End If
Do you know any vba courses (free would be best but I'am willing to pay a bit) that would broaden my horizons so I don't have to waste your time like this again?
I tried to work it out with chat gpt, chat created me a macro that opens the files but the rest wouldnt work as it didnt use my macro to edit opened source files and it didnt copy a thing from them.