Paste then select row

justDave

Board Regular
Joined
Mar 2, 2006
Messages
83
Hi all,

Sorry for all the questions lately!....

I am using the following code (shamelessly taken from the MS site for UserForms) to copy and paste data into a worksheet:

ws.Cells(iRow, 1).Value = Me.TextBox1.Value
ws.Cells(iRow, 2).Value = Me.TextBox2.Value

What I would then like to do is select the row which the data is pasted into. I've tried ActiveCell.EntireRow.Select but this selects the row which was copied from - sorry for the basic question but could anyone tell me how to select the correct row?

Many thanks,

Dave
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
ws.Cells(iRow, 1).Value = Me.TextBox1.Value

in English means worksheet cells (row, column 1) is the same as textbox1 value on a userform

What is iRow? 1,2,3,4...?
 
Upvote 0
Thank you for both of your quick replies.

I am using the UserForm methodology from this link (http://www.contextures.com/xluserform01.html) but I have changed the headings etc to suit my spreadsheet.

What I would like to do is highlight and shade the row whenever the UserForm is used paste a row into my sheet. There are only 2 'iRows': Task Number and Task Description.
 
Upvote 0
VoG, all,

Sorry to bug you again but how would the code alter if I only want to select and colour the first 6 columns instead of the whole row?
 
Upvote 0
Amazing, thank you!

One final question (hopefully!) why does the Font.Bold = True function not work when I attach it to the end of that code?
 
Upvote 0
This should work

Code:
With ws.Cells(iRow, 1).Resize(, 6)
    .Interior.ColorIndex = 6
    .Font.Bold = True
End With
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,462
Members
452,915
Latest member
hannnahheileen

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