mm_the_matrix
Gebruiker
- Lid geworden
- 1 aug 2005
- Berichten
- 79
Vanuit een managementsysteem halen wij lijsten deze worden in exel aangeleverd.
helaas staat niet overal het afdelingsnummer, alleen bij het eerste keer dat deze voorkomt.
is er een functie in access dat de waarde van een veld wordt overgenomen en ingevuld tot de volgende waarde wordt bereikt.
in exel wordt het nu op de volgende manier opgelost
maar ik wil graag naar access zodat een hoop vervolgstappen automatische kunnen.
Sub FillColBlanks()
Dim wks As Worksheet
Dim rng As Range
Dim LastRow As Long
Dim col As Long
Set wks = ActiveSheet
With wks
col = ActiveCell.Column
'or
'col = .range("n1").column
Set rng = .UsedRange 'try to reset the lastcell
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Set rng = Nothing
On Error Resume Next
Set rng = .Range(.Cells(2, col), .Cells(LastRow, col)) _
.Cells.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "No blanks found"
Exit Sub
Else
rng.FormulaR1C1 = "=R[-1]C"
End If
'replace formulas with values
With .Cells(1, col).EntireColumn
.Value = .Value
End With
End With
End Sub
helaas staat niet overal het afdelingsnummer, alleen bij het eerste keer dat deze voorkomt.
is er een functie in access dat de waarde van een veld wordt overgenomen en ingevuld tot de volgende waarde wordt bereikt.
in exel wordt het nu op de volgende manier opgelost
maar ik wil graag naar access zodat een hoop vervolgstappen automatische kunnen.
Sub FillColBlanks()
Dim wks As Worksheet
Dim rng As Range
Dim LastRow As Long
Dim col As Long
Set wks = ActiveSheet
With wks
col = ActiveCell.Column
'or
'col = .range("n1").column
Set rng = .UsedRange 'try to reset the lastcell
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Set rng = Nothing
On Error Resume Next
Set rng = .Range(.Cells(2, col), .Cells(LastRow, col)) _
.Cells.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "No blanks found"
Exit Sub
Else
rng.FormulaR1C1 = "=R[-1]C"
End If
'replace formulas with values
With .Cells(1, col).EntireColumn
.Value = .Value
End With
End With
End Sub