View Single Post
  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Does B1 contain a real date or does it contain a number from 1 to 31?

Maybe something like this will get you started.

Option Explicit
Sub testme01()


Dim DestCell As Range
Dim myValue As Double
Dim DayValue As Variant
Dim myMsg As String

With Worksheets("sheet1")
Set DestCell = .Range("a6")
myValue = .Range("B3").Value
DayValue = .Range("B1").Value

' or
' If IsDate(DayValue) Then
' DayValue = Day(DayValue)
' End If

myMsg = "Invalid Value"
If IsNumeric(DayValue) Then
DayValue = CLng(DayValue)
If DayValue < 1 _
Or DayValue 31 Then
'do nothing
Else
myMsg = ""
End If
End If

If myMsg < "" Then
MsgBox myMsg
Exit Sub
End If

DestCell.Offset(1, DayValue - 1).Value = myValue
End With

End Sub









tom300181 wrote:

I have a sheet that has a variable cell (date b1) and an entry for Sales
(B3). I also have A6 - AE6 with numbers 1-31,

I want a formula that will look at B1 and add the contents of B3 to to
A7-AE7 under the date from B1.

Can this be done?

Thanks

Tom

--
tom300181
------------------------------------------------------------------------
tom300181's Profile: http://www.excelforum.com/member.php...o&userid=21580
View this thread: http://www.excelforum.com/showthread...hreadid=391750


--

Dave Peterson