Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2010, 06:40 AM
LLG LLG is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populate a letter from a spreadsheet

Dear all

I have a spreadsheet that has the following list:
Seqential No., Reference No., Date, Debit, Credit.

I want to able to write a report or letter (in Excel) that has a narrative in the begining and then it would say:

The following are your Debit entries:
and the VBA code will insert all the rows ( Ref. No., Date, Debit amount) from the above sheet that have a debit value here.

Then my report/letter would say:
The follwoing are you Credit entries:
and the VBA code will insert all Credit rows ( Ref. No., Date, Credit amount) from the above sheet here.

The thing is, the number of rows with Debit or Credit change from one month to another and from one customer to another.

Can somebody please help.
ps. My knowledge of VBA is zero.
 
Old June 21st, 2010, 06:49 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Here is a sample

Code:
Sub Narrate_Letter()
Dim oWS As Worksheet
Dim oDS As Worksheet
Set oWS = Worksheets.Add
Set oDS = ActiveWorkbook.Sheets("debit")
oWS.Range("A1").Value = "The following are your Debit entries:"
oDS.UsedRange.Copy Destination:=oWS.Range("A2")
End Sub
I have assumed the debit entries to be in a sheet called 'debit'

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old June 21st, 2010, 07:06 AM
LLG LLG is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populate from a spreadsheet.

Thank you Shasur,

but I am afraid the code you gave me did the following:

1- created a new sheet in my workbook.
2- filled the first line in the spreadsheet with "The following are your Debit entries:"
3- Copied all the data from my original list here regardless of whether it is debit or credit.

I think we need to try again, but thanks all the same.
LLG





Similar Threads
Thread Thread Starter Forum Replies Last Post
Letter replace in hangman. martoufmarty Javascript How-To 12 June 17th, 2008 12:30 AM
search first letter keyvanjan Classic ASP Basics 2 May 17th, 2006 01:47 AM
check if first char is a letter crmpicco Javascript How-To 7 October 20th, 2005 05:42 AM
I have records where I need to replace one letter gilgalbiblewheel Classic ASP Databases 2 March 11th, 2005 02:29 AM
how can i get the drive letter (e.g. F:) of the ne arif_1947 VS.NET 2002/2003 0 October 5th, 2004 12:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.