Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to move the range down in excel ?
Message
 
 
À
11/12/2008 04:50:52
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01365010
Message ID:
01366599
Vues:
13
>Hi,
>After I Export a file to a Excel worksheet,
>how can I sum up a column and give a total at the last row ?
>
>Please advise.
>
>Derek

I'm passing an array of column headers into my funciton and the 5th element of the array tells me if I want to add some formula to the column. Here is a code
IF TYPE("taHeader_Info[m.lnK,5]")="C" AND !EMPTY(taHeader_Info[m.lnK,5]) && There is a formula or text cell
				lcEnd = IIF(m.lnK > 26, CHR(INT((m.lnK - 1) / 26) + 64), "") + ;
					CHR(((m.lnK - 1) % 26) + 65)
				
				lcStartRow = ALLTRIM(STR(m.lnLines + m.lnOffset + 1))
				
				lcEndRow = ALLTRIM(STR(m.lnTotalRows))

				DO CASE				

				CASE taHeader_Info[m.lnK,5] = "TEXT"
					loSheet.Cells(lnTotalRows + 2,m.lnK).VALUE = "TOTALS:"
					loSheet.Cells(lnTotalRows + 2,m.lnK).Font.Bold  = .T.
					loSheet.Cells(lnTotalRows + 2,m.lnK).Font.NAME = 'Tahoma'

				CASE taHeader_Info[m.lnK,5] ="SUM"
					loSheet.Cells(lnTotalRows + 2,m.lnK).formula = "=SUM(" + lcEnd + lcStartRow + ":" + lcEnd + lcEndRow + ")"
					IF !EMPTY(taHeader_Info[m.lnK,3]) && There is format information
						loSheet.Cells(lnTotalRows + 2,m.lnK).NumberFormat = taHeader_Info[m.lnK,3]
					ENDIF	
					
				CASE taHeader_Info[m.lnK,5] ="COUNT"
					loSheet.Cells(lnTotalRows + 2,m.lnK).formula = "=COUNTA(" + lcEnd + lcStartRow + ":" + lcEnd + lcEndRow + ")"
					IF !EMPTY(taHeader_Info[m.lnK,3]) && There is format information
						loSheet.Cells(lnTotalRows + 2,m.lnK).NumberFormat = taHeader_Info[m.lnK,3]
					ENDIF	
					
				ENDCASE
			ENDIF
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform