Computing.Net > Forums > Programming > VB Excel applications question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

VB Excel applications question

Reply to Message Icon

Name: Bonnie
Date: August 5, 2002 at 15:17:11 Pacific
Comment:

I'm having problems trying to do a loop for a spreadsheet in VB for Excel. I have a spreadsheet with records that include the fields: district number, school number, and school name. The number of records will vary for each spreadsheet depending on how many schools I have. I'd like to copy and paste columns A:C to another worksheet after each change in district number with as little code as possible as I approximately 1200 schools. Any help would be appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: tech-fred
Date: August 6, 2002 at 03:32:22 Pacific
Reply:

Maybe should consider a database application
instead?


0

Response Number 2
Name: Orione999
Date: August 6, 2002 at 07:31:33 Pacific
Reply:

write all your records on a single sheet, delete sheet 2 and 3; after create a macro with this code:

Sub separation()
Dim CellaAttuale, CellaPrec As Integer
'Valore = Worksheets("Foglio1").Cells(1, 1).Value
CellaPrec = Worksheets("Foglio1").Cells(1, 1).Value
y = 0
For j = 2 To 6

CellaAttuale = Worksheets("Foglio1").Cells(j, 1).Value
If CellaAttuale CellaPrec Then
MsgBox (CellaAttuale & " (cella attuale) diversa dalla prec: " & CellaPrec)
Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = CellaAttuale
Worksheets(Worksheets.Count).Cells(j, 1).Value = Worksheets("Foglio1").Cells(j, 1).Value
y = 0
Else
If Worksheets.Count > 1 Then
y = y + 1
Worksheets(Worksheets.Count).Cells(y, 1).Value = Worksheets("Foglio1").Cells(j, 1).Value
End If
End If

CellaPrec = CellaAttuale
Next j

End Sub

It doesn't work properly, it's just an idea to improve...
I hope an useful examble, try it and improve the code, otherwise to pass to a DB is the best thing to do (like tech-fred said)...



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Ada Help again what is a scripting langu...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB Excel applications question

VB & Excell...a question. help!!! www.computing.net/answers/programming/vb-amp-excella-question-help/9461.html

link excel chart to vb.net www.computing.net/answers/programming/link-excel-chart-to-vbnet/14244.html

VB macro www.computing.net/answers/programming/vb-macro/16000.html