English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to write a vba with date range as criteria.
Search a range of cells with given criteria and replace cell value with its corresponding value.
Example of Criteria :
1Jan 06 - 31 Jan 06 return value as Bazel
1Feb 06 - 28 Feb 06 return value as Cairns

2007-08-23 14:57:49 · 5 answers · asked by Antonia 2 in Computers & Internet Programming & Design

5 answers

I agree with Scott. Just put the name of your cell range in where he put the double questionmarks. If you are referring to the actual cells like A1:D5 put that in quotes ("A1:D5"). If you are referring to a named range, just type in the name of the range. All you should have to do afterwards is just run the procedure.

As the first answerer said, Alt + F11 will get you to the VBE window.

2007-08-27 07:18:04 · answer #1 · answered by devilishblueyes 7 · 0 0

Excel Vba Date

2016-09-30 09:30:33 · answer #2 · answered by ? 3 · 0 0

Hi,
if u have dates written in particular range, then u know no. of rows and columns where date is written.
press Alt-F11, VBA window will open, (Goto Insert menu) insert a module thereafter insert a subroutine and write the following code:
----------------------------------------------------------
assuming u have dates written in 10 rows and 10 columns.
Public Sub e()
Dim r As Integer,c as integer
For r = 1 To 10
For c = 1 To 10
If Sheet1.Cells(r, c) = #10/10/2007# Then Sheet1.Cells(r, c) = "Replace"
Next c
Next r
End Sub
----------------------------------------------------------
if u have no. of replacements then use that no. of 'If' statement for each replacement.

2007-08-23 19:37:50 · answer #3 · answered by iqbal 4 · 0 0

Try changing the last line to: .Range("inventory").AutoFilter field:=1, Criteria1:= txtDate.Value

2016-05-21 03:38:00 · answer #4 · answered by ? 3 · 0 0

sub date_to_text_value()
dim cell_range as range
dim cel as range
set cell_range=range(??)
for each cel in cell_range.cells
if cel.value=>date(2006,01,06) and cel.value<=date(2006,01,31) then cel.value="Bazel"
if cel.value=>date(2006,02,01) and cel.value<=date(2006,02,28) then cel.value="Cairns"
next cel
end sub

2007-08-25 17:34:31 · answer #5 · answered by Anonymous · 2 0

fedest.com, questions and answers