Sjon1974
New Member
- Joined
- Apr 1, 2020
- Messages
- 38
- Office Version
- 365
- Platform
- Windows
I am making a file that imports a .CSV en copy relative data to other sheet. (with a lot of help from Fluff
But before i filter and copy i want to check and fill empty cells (see foto)
If cell A is empty but cell F is not then copy data A to E from above in A to E in empty spots?
I have been trying the following script but i cannot get it to work
VBA Code:
Private Sub CMB1_Click()
Dim ws As Worksheet, strFile As String
Worksheets("Import").Range("A1:BH250").Clear
Set ws = ActiveWorkbook.Sheets("Import") 'set to current worksheet name
strFile = Application.GetOpenFilename("CSV File (*.csv),*.csv", , "Please select text file...")
With ws.QueryTables.Add(Connection:="TEXT;" & strFile, Destination:=ws.Range("A1"))
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh
End With
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastRow As Long
Dim Cl As Range
Set ws1 = ThisWorkbook.Sheets("Import")
Set ws2 = ThisWorkbook.Sheets("Database")
lastRow = ws2.Cells(Rows.Count, "A").End(xlUp).Row
ws1.Range("A7").AutoFilter 1, "IM*"
ws1.AutoFilter.Range.Offset(1).EntireRow.Copy ws2.Range("a" & lastRow + 1)
ws1.AutoFilterMode = False
Call deleteBlankRows
End Sub
But before i filter and copy i want to check and fill empty cells (see foto)
If cell A is empty but cell F is not then copy data A to E from above in A to E in empty spots?
I have been trying the following script but i cannot get it to work
VBA Code:
Sub FillColBlanks_Offset()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets("Import")
'by Rick Rothstein 2009-10-24
'fill blank cells in column with value above
'https://www.contextures.com/xlDataEntry02.html
Dim Area As Range, LastRow As Long
On Error Resume Next
LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, _
LookIn:=xlFormulas).Row
For Each Area In ActiveCell.EntireColumn(1).Resize(LastRow). _
SpecialCells(xlCellTypeBlanks).Areas
Area.Value = Area(1).Offset(-1).Value
Next
End Sub