Mám tento kód
Sub fill()
Dim rg As Range
Set rg = Range("a1")
Set rg = Range(rg, Cells(ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count - 1, rg.Column))
On Error Resume Next
Set rg = rg.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not rg Is Nothing Then
rg.Value = "1/1/2020"
End If
End Sub
ale to nefunguje, ako som chcel.
Potrebujem vyhľadávať v celom rade pracovných hárkov programu Excel (a1: bj1223) a skontrolovať všetky bunky typu "typ dátumu". keď nájde bunku, ktorá je "typ dátumu" a je prázdna, musím do tejto bunky pridať hodnotu "1/1/2020".
Ďakujem
odpovede:
3 pre odpoveď č. 1Je to to, čo sa snažíte? Najprv sa vyhľadajú prázdne bunky a potom skontroluje, či každá bunka v tomto rozsahu má špecifický formát "dd/mm/yyyy"
Zmeňte to podľa potreby.
Sub Sample()
Dim rng As Range, aCell As Range
Dim blnkCells As Range
Set rng = ThisWorkbook.Sheets("Sheet1").Range("A1:BJ1223")
On Error Resume Next
Set blnkCells = rng.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not blnkCells Is Nothing Then
For Each aCell In blnkCells
If aCell.NumberFormat = "dd/mm/yyyy" Then aCell.Value = "1/1/2020"
Next aCell
End If
End Sub