Hej Allan.
Prøv nedenstående hint.
Option Explicit
Const hil As String = "Best regards from Joergen"
Const MainsheetName As String = "Hovedark"
Const Startcell As String = "C3"
'----------------------------------------------------------
' Procedure : FromMainsheet
' Date : 20051217
' Author : Joergen Bondesen
' Purpose : Copy Table row from Table in
' 'Const MainsheetName' to "Ark" & X
' X is digits in 1 coloum in Table
' Note : "Ark" = Sheetname
'----------------------------------------------------------
'
Sub FromMainsheet()
Dim RMaintable As Range
Dim TotNoOfSheets As Long
Dim TotNoTableRows As Long
Dim cell As Range
Dim countshno As Long
Dim rowno As Long
Dim x As Long
Dim newrange As String
Set RMaintable = Worksheets(MainsheetName) _
.Range(Startcell).CurrentRegion
TotNoOfSheets = ActiveWorkbook.Worksheets.Count
TotNoTableRows = RMaintable.Rows.Count
'// Sheets controle
If (TotNoOfSheets - 1) < TotNoTableRows Then
MsgBox "Your table have rows: " & TotNoTableRows _
& vbCr & vbCr & "and you have max worksheets: " _
& (TotNoOfSheets - 1), vbCritical, hil
End
End If
For x = 1 To (TotNoTableRows + 1)
If x = 1 Then
If UCase(Worksheets(1).Name) <> _
UCase(MainsheetName) Then
MsgBox "Your 1 sheetname is not: " _
& MainsheetName, vbCritical, hil
End
End If
Else
If UCase(Worksheets(x).Name) <> _
UCase("Ark" & (x - 1)) Then
MsgBox "SheetName: " & Worksheets(x).Name _
& " must be: " & "Ark" & (x - 1), _
vbCritical, hil
End
End If
End If
Next x
'// Table copy
For Each cell In RMaintable.Resize(TotNoTableRows, 1)
rowno = Sheets("Ark" & cell.Value) _
.Range("A" & Rows.Count).End(xlUp).Row
newrange = cell.Resize(1, RMaintable.Columns.Count) _
.Address
Worksheets(MainsheetName).Range(newrange).Copy _
Destination:=Worksheets("Ark" & cell.Value) _
.Range("A" & (rowno + 1))
Next cell
End Sub
--
Med venlig hilsen
Jørgen Bondesen
"Allan Møller" <allanatallanmdotdk> wrote in message
news:43a35380$0$15794$14726298@news.sunsite.dk...
> Jeg har et ark som jeg kalder for "hovedark"
> Derudover har jeg ca. 10 ark som bliver kaldt ark1 til ark 10
>
> I hovedarket er en kolonne en værdi fra 1 til 10 - den linje som
> er 1 skal kopieres til ark1 og linje som er 2 skal til ark 2 osv.
>
> Kan dette gøres automatisk og hvis ja kan nogen give mig et hint til
> hvordan
> jeg kommer videre.
>
> Det er Excel 2002 DK.
>
>
> Mvh. Allan