View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul Robinson Paul Robinson is offline
external usenet poster
 
Posts: 208
Default A little help needed please...

Hi
Maybe this?
Sub UpdateYear()
Dim sCell As Range
Dim tCell As Range
Dim i As Integer
For i = 1 To 5
Set sCell = Range("A1:A5")
Set tCell = Range("B1:B5")
If Not tCell(i, 1).Value = "" Then
tCell(i, 1).Value = sCell(i, 1).Value
tCell(i,1).NumberFormat = "YYYY"
End If
Next i
End Sub

More probably this?
Sub UpdateYear()
Dim sCell As Range
Dim tCell As Range
Dim i As Integer
Set sCell = Range("A1:A5")
Set tCell = Range("B1:B5")
For i = 1 To 5
If Not tCell(i, 1).Value = "" Then
tCell(i, 1).Value = sCell(i, 1).Value
tCell(i,1).NumberFormat = "YYYY"
End If
Next i
End Sub

regards
Paul

On Feb 15, 11:47*am, Vacuum Sealed wrote:
Hi all

For some reason I can't see the forest through the trees in this If,
Then, Next code...

Sub UpdateYear()
Dim sCell As Range
Dim tCell As Range
Dim i As Integer
For i = 1 To 5
Set sCell = Range("A1:A5")
Set tCell = Range("B1:B5")
If Not Cells(i, tCell) = "" Then
* * *Cells(i, tCell).Value = Cells(i, sCell)
* * *Cells(i, tCell).NumberFormat = "YYYY"
End If
Next i
End Sub

As always

TIA
Mick