Cutting a variable number of rows from set number of columns

SconnorA

New Member
Joined
Jun 22, 2015
Messages
11
I am trying to cut a varying number of rows, user entered index n, and paste these data into the j'th column of a new sheet.

Here are the relevant commands I have trying to do so; NOTE: "NAME" is just so I didn't have to type out the workbook name, I'm posting this on a separate computer not running the Macro

Code:
Workbooks("NAME").Sheets(6).Range("A1:E" & n).Cut
Workbooks("NAME").Sheets(7).Cells(1, j).Paste

The error appears in the second line of what is shown above. Thanks in advance for your help.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Must change "j" to "10".
Code:
Workbooks("NAME").Sheets(6).Range("A1:E" & n).Cut
Workbooks("NAME").Sheets(7).Cells(1, [COLOR="#FF0000"]10[/COLOR]).Paste
I do not believe your showing us the whole script.
 
Last edited:
Upvote 0
Sorry for not including all the code, here is what I have now.

Code:
Option Explicit

Sub CurveFit()
    Dim i As Single, n As Single, s As Single, j As Single


For j = 1 To 31 Step 6
    n = InputBox("Enterthe number of data sets")
    s = InputBox("Enter the sheet index number of these data")


    For i = 1 To n Step 1
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(s).Cells(1, i).Resize(640).Copy 'Copies all 640 values from the i'th column
        Sheet1.Range("C10").PasteSpecial xlPasteValues 'Paste values from column i
        Workbooks("Fresnel Curve Fitting - Macro Enabled.xlsm").Activate 'ensures the proper workbook is activated for solver
        SolverReset 'resets defaults
        SolverOk SetCell:="$E$7", MaxMinVal:=2, ByChange:="$B$2:$B$4" 'necessary parameters
        SolverSolve True 'accepts the output and keeps those values
        SolverFinish
        Sheet1.Range("B2").Copy
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(6).Cells(i, "A").PasteSpecial xlPasteValues
        Sheet1.Range("B3").Copy
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(6).Cells(i, "B").PasteSpecial xlPasteValues
        Sheet1.Range("B4").Copy
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(6).Cells(i, "C").PasteSpecial xlPasteValues
        Sheet1.Range("B5").Copy
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(6).Cells(i, "D").PasteSpecial xlPasteValues
        Sheet1.Range("E7").Copy
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(6).Cells(i, "E").PasteSpecial xlPasteValues
    Next i
  Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(6).Range(Cells(1, 1), Cells(n, 5)).Cut
  Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Sheets(7).Cells(2, j).Paste
Next j
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,106
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top