Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For Each - Range Cell

Hello

How can I make to get data from a .dbf file from a Excel Macro, and replace it into a Cell in a determinated Sheet.

I made something like this.

Dim rng As Range
Set rng = Sheets("07").Range("B7:B10")
'Range("B56").Select
For Each Cell In rng
If Cell < "" Then

'---- here I want to select the value of the next column , for example if the cursor is positioning at B7 with value "03/07/2004" I would like to obtaint C7 value (only "AM" and "PM" is saved in this cells), then with this 2 values I need to look into a .DBF file located at c:\fax named faxdata.dbf wich has a column called datefax (type Date) and another column called AMPM (type Char 2) and a third column called Lamount (type Integer) and what I need is to copy this value into the next column in the same Sheet (D7) <-------'

End If
Next

Please make it as simple as possible because I am new in macros, however any suggest wil be very appreciate it.

Regards

PE

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default For Each - Range Cell

Hi
use
msgbox cell.offset(0,1).value

-----Original Message-----
Hello

How can I make to get data from a .dbf file from a Excel

Macro, and replace it into a Cell in a determinated Sheet.

I made something like this.

Dim rng As Range
Set rng = Sheets("07").Range("B7:B10")
'Range("B56").Select
For Each Cell In rng
If Cell < "" Then

'---- here I want to select the value of

the next column , for example if the cursor is positioning
at B7 with value "03/07/2004" I would like to obtaint C7
value (only "AM" and "PM" is saved in this cells), then
with this 2 values I need to look into a .DBF file located
at c:\fax named faxdata.dbf wich has a column called
datefax (type Date) and another column called AMPM (type
Char 2) and a third column called Lamount (type Integer)
and what I need is to copy this value into the next column
in the same Sheet (D7) <-------'

End If
Next

Please make it as simple as possible because I am new in

macros, however any suggest wil be very appreciate it.

Regards

PE

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default For Each - Range Cell

Thank you Frank, I got the next column value, but Could you help me with the rest?.

PE

"Frank Kabel" wrote:

Hi
use
msgbox cell.offset(0,1).value

-----Original Message-----
Hello

How can I make to get data from a .dbf file from a Excel

Macro, and replace it into a Cell in a determinated Sheet.

I made something like this.

Dim rng As Range
Set rng = Sheets("07").Range("B7:B10")
'Range("B56").Select
For Each Cell In rng
If Cell < "" Then

'---- here I want to select the value of

the next column , for example if the cursor is positioning
at B7 with value "03/07/2004" I would like to obtaint C7
value (only "AM" and "PM" is saved in this cells), then
with this 2 values I need to look into a .DBF file located
at c:\fax named faxdata.dbf wich has a column called
datefax (type Date) and another column called AMPM (type
Char 2) and a third column called Lamount (type Integer)
and what I need is to copy this value into the next column
in the same Sheet (D7) <-------'

End If
Next

Please make it as simple as possible because I am new in

macros, however any suggest wil be very appreciate it.

Regards

PE

.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default For Each - Range Cell

Me Again,

I complete my macro and it works but until date 09/07/04, the rest idk why? but it's being ignored.

Ill show you so you can have a better idea of what I wanted to do, I need your help please!!

Sub Macro1()
Workbooks.Open Filename:="C:\TEMP\faxdata.DBF"
Windows("C2004.xls").Activate
Dim rng As Range
Set rng = Sheets("07").Range("B7:B80")
'at B7 begins my dates from 01/07/04 until 31/07/04
For Each Cell In rng
If Cell < "" Then
Data = Cell ' here I keep my Date
OPE = IIf(Cell.Offset(0, 1).Value = "a", "AM", "PM")
'I change a/p to AM/PM 'cause in faxdata the value is like that
Windows("faxdata.dbf").Activate
With Worksheets("faxdata").Range("A1:A1000")
Set c = .Find(Data, LookIn:=xlValues) 'I found this example and I take it
'but Idk how it works exactly LookIn:=xlValues??
If Not c Is Nothing Then
'I guess this means If c has a value or not, right?
If OPE = "AM" Then
adrow = 0
Else
adrow = 18
End If
Cell.Offset(0, 2).Value = Cells(c.Row + adrow, 11)
Cell.Offset(0, 3).Value = Cells(c.Row + adrow + 1, 11)
Cell.Offset(0, 4).Value = Cells(c.Row + adrow + 2, 11)
Cell.Offset(0, 7).Value = Cells(c.Row + adrow + 12, 11)
'at C2004.xls I replace the values i need it
End If
End With
End If
Windows("C2004.xls").Activate
Next
End Sub


Help me please

Regards
PE
"Frank Kabel" wrote:

Hi
use
msgbox cell.offset(0,1).value

-----Original Message-----
Hello

How can I make to get data from a .dbf file from a Excel

Macro, and replace it into a Cell in a determinated Sheet.

I made something like this.

Dim rng As Range
Set rng = Sheets("07").Range("B7:B10")
'Range("B56").Select
For Each Cell In rng
If Cell < "" Then

'---- here I want to select the value of

the next column , for example if the cursor is positioning
at B7 with value "03/07/2004" I would like to obtaint C7
value (only "AM" and "PM" is saved in this cells), then
with this 2 values I need to look into a .DBF file located
at c:\fax named faxdata.dbf wich has a column called
datefax (type Date) and another column called AMPM (type
Char 2) and a third column called Lamount (type Integer)
and what I need is to copy this value into the next column
in the same Sheet (D7) <-------'

End If
Next

Please make it as simple as possible because I am new in

macros, however any suggest wil be very appreciate it.

Regards

PE

.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
RANGE EXCEL copy cell that meets criteria in a range confused Excel Worksheet Functions 3 March 27th 08 01:41 PM
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM


All times are GMT +1. The time now is 03:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"