Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default trouble with macro

I have two workbooks and am trying to copy the currency value (if entered) in
col B, in rows 19 - 57 only from the "Data Input" WS in WB "Daily Balance
Today" and copy those values to the "Pending" WS in the "Pending and Short"
WB into the next availabel cell in col C. This workbook is a running total
so I need to add the information to the bottom of the spreadsheet. If values
are copied, I need to copy the text from Col A and the date in Col D from the
Data Input WS and copy that text to Col B in the Pending WS on the same row
as the currency value. This code is not working for me and I'm not sure what
is wrong. Thanks in advance for your assistance.


Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:57").SpecialCells(xlConstants, xlTextValues)
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4))
Set rng2 = Intersect(rng.EntireRow, .Columns(2))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default trouble with macro

First, you use xlTextValues, but it sounds like you are looking for a
currency value (xlNumbers)? If that were corrected or is correct, then

you have .Range("B19:57")
which should be .Range("B19:B57") It that were corrected, then

right now it copies columns A:D to A and then copies B to D

It uses column B in the Pending WS to determine the next available column.

You say you want to copy A, D and I assume B (the currency value) to column
B of Pending - doesn't make much sense - 3 cells to 1.

Also, it assumes the Daily Balance Today.xls is the activeworkbook when it
is run and that Pending and Short.xls is closed.

Perhaps the fix is

Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:B57").SpecialCells(xlConstants, xlNumbers)
if rng.count 1 then
Msgbox "More than one row is found - exiting"
exit sub
End if
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 2))
Set rng2 = Intersect(rng.EntireRow, .Columns(4))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub


--
Regards,
Tom Ogilvy


"glensfallslady" wrote in message
...
I have two workbooks and am trying to copy the currency value (if entered)
in
col B, in rows 19 - 57 only from the "Data Input" WS in WB "Daily Balance
Today" and copy those values to the "Pending" WS in the "Pending and
Short"
WB into the next availabel cell in col C. This workbook is a running
total
so I need to add the information to the bottom of the spreadsheet. If
values
are copied, I need to copy the text from Col A and the date in Col D from
the
Data Input WS and copy that text to Col B in the Pending WS on the same
row
as the currency value. This code is not working for me and I'm not sure
what
is wrong. Thanks in advance for your assistance.


Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:57").SpecialCells(xlConstants, xlTextValues)
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4))
Set rng2 = Intersect(rng.EntireRow, .Columns(2))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default trouble with macro

Hi Again Tom,

I'm looking to copy all rows that have a value in col B. The code below
keeps firing the message box. I will always have more than one row that I
need to copy to the new sheet so should I just delete this code? Thanks
again.

if rng.count 1 then
Msgbox "More than one row is found - exiting"
exit sub


"Tom Ogilvy" wrote:

First, you use xlTextValues, but it sounds like you are looking for a
currency value (xlNumbers)? If that were corrected or is correct, then

you have .Range("B19:57")
which should be .Range("B19:B57") It that were corrected, then

right now it copies columns A:D to A and then copies B to D

It uses column B in the Pending WS to determine the next available column.

You say you want to copy A, D and I assume B (the currency value) to column
B of Pending - doesn't make much sense - 3 cells to 1.

Also, it assumes the Daily Balance Today.xls is the activeworkbook when it
is run and that Pending and Short.xls is closed.

Perhaps the fix is

Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:B57").SpecialCells(xlConstants, xlNumbers)
if rng.count 1 then
Msgbox "More than one row is found - exiting"
exit sub
End if
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 2))
Set rng2 = Intersect(rng.EntireRow, .Columns(4))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub


--
Regards,
Tom Ogilvy


"glensfallslady" wrote in message
...
I have two workbooks and am trying to copy the currency value (if entered)
in
col B, in rows 19 - 57 only from the "Data Input" WS in WB "Daily Balance
Today" and copy those values to the "Pending" WS in the "Pending and
Short"
WB into the next availabel cell in col C. This workbook is a running
total
so I need to add the information to the bottom of the spreadsheet. If
values
are copied, I need to copy the text from Col A and the date in Col D from
the
Data Input WS and copy that text to Col B in the Pending WS on the same
row
as the currency value. This code is not working for me and I'm not sure
what
is wrong. Thanks in advance for your assistance.


Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:57").SpecialCells(xlConstants, xlTextValues)
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4))
Set rng2 = Intersect(rng.EntireRow, .Columns(2))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default trouble with macro

You can delete it if wish.

--
Regards,
Tom Ogilvy

"glensfallslady" wrote in message
...
Hi Again Tom,

I'm looking to copy all rows that have a value in col B. The code below
keeps firing the message box. I will always have more than one row that I
need to copy to the new sheet so should I just delete this code? Thanks
again.

if rng.count 1 then
Msgbox "More than one row is found - exiting"
exit sub


"Tom Ogilvy" wrote:

First, you use xlTextValues, but it sounds like you are looking for a
currency value (xlNumbers)? If that were corrected or is correct, then

you have .Range("B19:57")
which should be .Range("B19:B57") It that were corrected, then

right now it copies columns A:D to A and then copies B to D

It uses column B in the Pending WS to determine the next available
column.

You say you want to copy A, D and I assume B (the currency value) to
column
B of Pending - doesn't make much sense - 3 cells to 1.

Also, it assumes the Daily Balance Today.xls is the activeworkbook when
it
is run and that Pending and Short.xls is closed.

Perhaps the fix is

Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:B57").SpecialCells(xlConstants, xlNumbers)
if rng.count 1 then
Msgbox "More than one row is found - exiting"
exit sub
End if
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 2))
Set rng2 = Intersect(rng.EntireRow, .Columns(4))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub


--
Regards,
Tom Ogilvy


"glensfallslady" wrote in
message
...
I have two workbooks and am trying to copy the currency value (if
entered)
in
col B, in rows 19 - 57 only from the "Data Input" WS in WB "Daily
Balance
Today" and copy those values to the "Pending" WS in the "Pending and
Short"
WB into the next availabel cell in col C. This workbook is a running
total
so I need to add the information to the bottom of the spreadsheet. If
values
are copied, I need to copy the text from Col A and the date in Col D
from
the
Data Input WS and copy that text to Col B in the Pending WS on the same
row
as the currency value. This code is not working for me and I'm not
sure
what
is wrong. Thanks in advance for your assistance.


Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:57").SpecialCells(xlConstants, xlTextValues)
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4))
Set rng2 = Intersect(rng.EntireRow, .Columns(2))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and
Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default trouble with macro

Hi Tom, the data is moving to the correct WB and WS however the informatoin
is going to the wrong columns and not cancatinating. I've played around with
the code but just can't get it correct. I'd like to add the text "text"
between the copied data from Col A and Col D from the source WB to the
Pending and Short Log or WB when it copies to Col B. This will help me
understand the code I think. I appreciate your help, thanks

Source WB Pending and Short WB

Col A "to be keyed" Col D goes to Col B
Col B goes to Col C

"Tom Ogilvy" wrote:

You can delete it if wish.

--
Regards,
Tom Ogilvy

"glensfallslady" wrote in message
...
Hi Again Tom,

I'm looking to copy all rows that have a value in col B. The code below
keeps firing the message box. I will always have more than one row that I
need to copy to the new sheet so should I just delete this code? Thanks
again.

if rng.count 1 then
Msgbox "More than one row is found - exiting"
exit sub


"Tom Ogilvy" wrote:

First, you use xlTextValues, but it sounds like you are looking for a
currency value (xlNumbers)? If that were corrected or is correct, then

you have .Range("B19:57")
which should be .Range("B19:B57") It that were corrected, then

right now it copies columns A:D to A and then copies B to D

It uses column B in the Pending WS to determine the next available
column.

You say you want to copy A, D and I assume B (the currency value) to
column
B of Pending - doesn't make much sense - 3 cells to 1.

Also, it assumes the Daily Balance Today.xls is the activeworkbook when
it
is run and that Pending and Short.xls is closed.

Perhaps the fix is

Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:B57").SpecialCells(xlConstants, xlNumbers)
if rng.count 1 then
Msgbox "More than one row is found - exiting"
exit sub
End if
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 2))
Set rng2 = Intersect(rng.EntireRow, .Columns(4))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub


--
Regards,
Tom Ogilvy


"glensfallslady" wrote in
message
...
I have two workbooks and am trying to copy the currency value (if
entered)
in
col B, in rows 19 - 57 only from the "Data Input" WS in WB "Daily
Balance
Today" and copy those values to the "Pending" WS in the "Pending and
Short"
WB into the next availabel cell in col C. This workbook is a running
total
so I need to add the information to the bottom of the spreadsheet. If
values
are copied, I need to copy the text from Col A and the date in Col D
from
the
Data Input WS and copy that text to Col B in the Pending WS on the same
row
as the currency value. This code is not working for me and I'm not
sure
what
is wrong. Thanks in advance for your assistance.


Sub copydata()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range

With Worksheets("Data Input")
Set rng = .Range("B19:57").SpecialCells(xlConstants, xlTextValues)
If Not rng Is Nothing Then
Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4))
Set rng2 = Intersect(rng.EntireRow, .Columns(2))
Else
Exit Sub
End If
End With

Dim bk as Workbook
set bk = Workbooks.Open(C:\Pending and Short Log\Pending and
Short.xls")
set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)

rng1.Copy rng3.Offset(0, -1)
rng2.Copy rng3.Offset(0, 2)

End Sub









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
macro trouble jen_writer Excel Discussion (Misc queries) 1 February 14th 07 11:47 PM
MACRO TROUBLE HELP Excel Discussion (Misc queries) 2 June 7th 06 04:09 PM
Excel macro & MS XP OS trouble Gary Excel Programming 0 July 1st 04 03:16 PM
Having trouble with simple macro! Simon Lloyd[_397_] Excel Programming 1 March 2nd 04 06:23 PM
Macro trouble kdp Excel Programming 1 February 25th 04 10:25 PM


All times are GMT +1. The time now is 10:27 PM.

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

About Us

"It's about Microsoft Excel"